Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8100391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:43:34+00:00 2026-06-05T22:43:34+00:00

i use this code in my app. just found is not correct when compare

  • 0

i use this code in my app. just found is not correct when compare korean

        for (NSString *lang in array){
        NSString *currentLang = [[MLLanguage sharedInstance] lang];
        BOOL flag = [lang isEqualToString:currentLang];
        NSLog(@"\n'%@' isEqual to '%@', %d\n%@\n%@", lang, currentLang, flag?1:0, [lang dataUsingEncoding:NSUTF8StringEncoding], [currentLang dataUsingEncoding:NSUTF8StringEncoding]);

wrong result: the two korean word compared as different

        2012-06-19 21:16:52.681 Motilink[10188:11903] -[MLSettingLanguageViewController             loadDownloadedData][Line 50] 
        'English' isEqual to '한국어', 0
        <456e676c 697368>
        <ed959cea b5adec96 b4>
        2012-06-19 21:16:52.682 Motilink[10188:11903] -[MLSettingLanguageViewController             loadDownloadedData][Line 50] 
        '한국어' isEqual to '한국어', 0
        <e18492e1 85a1e186 abe18480 e185aee1 86a8e184 8be185a5>
        <ed959cea b5adec96 b4>
        2012-06-19 21:16:52.682 Motilink[10188:11903] -[MLSettingLanguageViewController             loadDownloadedData][Line 50] 
        '中国语' isEqual to '한국어', 0
        <e4b8ade5 9bbde8af ad>
        <ed959cea b5adec96 b4>

correct one:

        2012-06-19 21:35:00.908 Motilink[10188:11903] -[MLSettingLanguageViewController loadDownloadedData][Line 50] 
        'English' isEqual to '中国语', 0
        <456e676c 697368>
        <e4b8ade5 9bbde8af ad>
        2012-06-19 21:35:00.909 Motilink[10188:11903] -[MLSettingLanguageViewController             loadDownloadedData][Line 50] 
        '한국어' isEqual to '中国语', 0
        <e18492e1 85a1e186 abe18480 e185aee1 86a8e184 8be185a5>
        <e4b8ade5 9bbde8af ad>
        2012-06-19 21:35:00.909 Motilink[10188:11903] -[MLSettingLanguageViewController loadDownloadedData][Line 50] 
        '中国语' isEqual to '中国语', 1
        <e4b8ade5 9bbde8af ad>
        <e4b8ade5 9bbde8af ad>

it seems that: NSString use encode by itself,

english only use 7 byte like ascii

chinese use use 9 byte maybe utf8

but in korean, it appear two different result,

does anyone know this

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T22:43:36+00:00Added an answer on June 5, 2026 at 10:43 pm

    The problem here is that you compare non-normalized strings. In Unicode, you can either use characters directly, or compose them from other characters. For example in German, there is the character “ä” which can be either represented by the codepoint “ä” or the sequence of code points for “¨” and “a”.

    You have the same problem here with the Korean strings: While they look the same in output, one of them is decomposed (which leads to the longer UTF-8 data representation) while the other isn’t.

    One way to work around this problem is to normalize all your strings using
    - [NSString precomposedStringWithCanonicalMapping]:

    BOOL flag = [[lang precomposedStringWithCanonicalMapping] isEqualToString:
                        [currentLang precomposedStringWithCanonicalMapping]];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use this code in my QT app QMap<QString,QMap> but there
I'm trying to use this fairly standard line of code in my app: [[UIApplication
I make call from my app with this code (i use webview because after
I tried to use this code but it doesn't work. http://developer.apple.com/library/ios/#samplecode/PageControl/Introduction/Intro.html Ld /Users/waitonza/Library/Developer/Xcode/DerivedData/Dr_Ngoo-aanknxmuodcgjicaigxevljxokeq/Build/Products/Debug-iphonesimulator/Dr Ngoo.app/Dr
I use this code to update data in database table. Can reuse same code
I use this code: http://blogswizards.com/plugin-development/sliding-boxes-and-captions-with-jquery On a simple gallery site I am building. Specifically
I use this code to process a date string coming in from a json
I use this code which is taken from MVC futures and attach the Attribute
I use this code to generate a random number. Random R = new Random(0);
I use this code to determine checkbox width and height: var chk = $('input[type=checkbox]:first');

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.