Localizing the Reading of Emoji on IOS 10.0 or Higher
UPDATE: Issue appears to be fixed in iOS 13.2! Yay!
UPDATE: After official release of iOS 13, the issue has been eclipsed/superceded by a worse issue (iOS 13 Text To Speech (TTS - AVSpeechSynthesisVoice) crashes for some users after update).
// original post:
After notifying Apple via the Feedback Assistant, it appears that this was a bug introduced somehow in IOS 10 that went unnoticed for three consecutive versions of IOS.
After testing with IOS 13 beta 5 (17A5547d), the issue doesn't appear.
They claim that the issue has been explicitly fixed from this point forward.
ios: localize emoji name (kCFStringTransformToUnicodeName)
There is no api for this job. Unicode character name is standardized only in English.
The macOS use localization files to achieve this.
You can find the location of The CharacterPalette app:
Option+click on the Apple menu and choose ‘System Information’ (called ‘System Profiler’ in earlier releases of OS X).
From the side menu, look under ‘Software’ and choose “Applications”
My app's location looks like this:
Locate the CharacterPalette.app
,right click -> show package,you can find the localization files :
But I can't open it correctly , the file is full of unreadable code.Maybe it's encrypted.
You may have to copy paste the names one by one.
Is there a framework or function for turning emoji into words?
This links to a repository containing the mapping from emoji unicode to description. Also check this answer.
To read it out, get familiar with AvSpeechSynthesizer
How to list (almost) all emojis in Swift for iOS 8 without using any form of lookup tables?
You can loop over those hex values with a Range
: 0x1F601...0x1F64F
and then create the String
s using a UnicodeScalar
:
for i in 0x1F601...0x1F64F {
guard let scalar = UnicodeScalar(i) else { continue }
let c = String(scalar)
print(c)
}
Outputs:
/p>
If you want all the emoji, just add another loop over an array of ranges:
// NOTE: These ranges are still just a subset of all the emoji characters;
// they seem to be all over the place...
let emojiRanges = [
0x1F601...0x1F64F,
0x2702...0x27B0,
0x1F680...0x1F6C0,
0x1F170...0x1F251
]
for range in emojiRanges {
for i in range {
guard let scalar = UnicodeScalar(i) else { continue }
let c = String(scalar)
print(c)
}
}
For those asking, the full list of available emojis can be found here: https://www.unicode.org/emoji/charts/full-emoji-list.html
A parsable list of unicode sequences for all emojis can be found in the emoji-sequences.txt
file under the directory for the version you're interested in here: http://unicode.org/Public/emoji/
As of 9/15/2021 the latest version of the emoji standard available on Apple devices is 13.1.
Xcode Objective-C: Text to speech is always in English even if the iPhone is set to another language
You can use [[[NSBundle mainBundle] preferredLocalizations] firstObject]
to find the application current language.
(If it's nil
or if your app is not localized you can use [[NSLocale currentLocale] languageCode]
instead, but this does not take care of the language specified in the settings, whenever the user changes the language of the app only, not for all the device)
This way you can specify the language with [AVSpeechSynthesisVoice voiceWithLanguage:]
and be sure you have the app language spoken.
Otherwise you can let the user choose the spoken language.
iOS Localization: Unicode character escape sequences, which have the form '\uxxxx' does not work
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 - br>
Strings-files, on the other hand, use \Unnnn
to denote a UTF-16 character,
and "UTF-16 surrogate pairs" for characters > U+FFFF:
"spanish-key" = "Espa\U00f1ol - \Ud83d\Ude00";
(This is the escaping used in "old style property lists", which you can see when printing
the description of an `NSDictionary.)
This (hopefully) answers your question
When to use "\Uxxxx" and "\uxxxx"?
But: As also noted by @gnasher729 in his answer, there is no need to use Unicode
escape sequences at all. You can simply insert the Unicode characters itself,
both in NSString
literals and in strings-files:
NSString *string = @"Español - ;
"spanish-key" = "Español - ;
Related Topics
How to Put View on Top of All Other Views in Swiftui
Swift 4 - Hmcharacteristictypeserialnumber Deprecated
Get Path of a File in a Data Set Located in Assets.Xcassets
Answers by Crashlytics - Adding Custom Event
Get User Preferred Temperature Setting in Macos
Show and Hide Window Instead of Terminating App on Close Click in Cocoa App
Pause Spritekit Scene When Iad Is Clicked in Swift
Quick Sort in Swift Is Giving Error
In Swift 3.1, Unsafemutablepointer.Initialize(From:) Is Deprecated
Dictionary of a Protocol Swift 4
Url(String:) Cannot Call Value of Non-Function Type 'string'
Cocoa: Simulating Command+Tab in Cgevent
How to Calculate Quadrangle for Visible Part of Vertical Plane
Make a Publisher from a Callback
Navigationlink Inside .Searchable Does Not Work
Error: 'string' Is Not Convertible to 'string!'