iOS Localization: Unicode character escape sequences, which have the form '\uxxxx' does not work

前端 未结 2 1483
不思量自难忘°
不思量自难忘° 2020-12-01 13:08

We have key-value pair in Localization.string file.

\"spanish-key\" = \"Espa\\u00f1ol\";

When we fetch and assign to label then app display

相关标签:
2条回答
  • 2020-12-01 13:30

    NSString literals and strings-files use different escaping rules.

    NSString literals use the same escape sequences as "normal" C-strings, in particular the "universal character names" defined in the C99 standard:

    \unnnn      - the character whose four-digit short identifier is nnnn
    \Unnnnnnnn  - the character whose eight-digit short identifier is nnnnnnnn
    

    Example:

    NSString *string = @"Espa\u00F1ol - \U0001F600"; // Español -                                                                     
    0 讨论(0)
  • 2020-12-01 13:37

    Just write the string in proper Unicode in Localization.string.

    "spanish-key" = "Español";
    
    0 讨论(0)
提交回复
热议问题