提交 39779764 编写于 作者: S sunyaozu

fix isRTL bug

Signed-off-by: Nsunyaozu <sunyaozu@huawei.com>
上级 a37fadde
......@@ -52,6 +52,7 @@ ohos_shared_library("preferred_language") {
config("intl_util_config") {
include_dirs = [
"include",
"//third_party/icu/icu4c/source",
"//third_party/icu/icu4c/source/common",
"//third_party/icu/icu4c/source/i18n",
......@@ -62,7 +63,6 @@ config("intl_util_config") {
ohos_shared_library("intl_util") {
public_configs = [ ":intl_util_config" ]
include_dirs = [
"include",
"//utils/native/base/include",
"//third_party/libxml2/include",
"//third_party/libphonenumber/cpp/src",
......
......@@ -13,11 +13,20 @@
* limitations under the License.
*/
#include "character.h"
#include <set>
#include "unicode/unistr.h"
namespace OHOS {
namespace Global {
namespace I18n {
static std::set<UCharDirection> RTLDirectionSet = {
U_RIGHT_TO_LEFT,
U_RIGHT_TO_LEFT_ARABIC,
U_RIGHT_TO_LEFT_EMBEDDING,
U_RIGHT_TO_LEFT_OVERRIDE,
U_RIGHT_TO_LEFT_ISOLATE
};
bool IsDigit(const std::string &character)
{
icu::UnicodeString unicodeString(character.c_str());
......@@ -44,7 +53,10 @@ bool IsRTLCharacter(const std::string &character)
icu::UnicodeString unicodeString(character.c_str());
UChar32 char32 = unicodeString.char32At(0);
UCharDirection direction = u_charDirection(char32);
return direction == UCharDirection::U_RIGHT_TO_LEFT;
if (RTLDirectionSet.find(direction) != RTLDirectionSet.end()) {
return true;
}
return false;
}
bool IsIdeoGraphic(const std::string &character)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册