Android ignores unicode soft hyphen (u00AD)
See original GitHub issueDescription:
On android soft-hyphen unicode u00AD
is ignored, neither the word break nor the hyphen are displayed correctly. Using u200B
is a workaround for getting better word wrapping results but is still missing the hyphen.
React Native version:
System:
OS: macOS 10.15.3
CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
Memory: 108.98 MB / 16.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 13.10.1 - /usr/local/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.13.7 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
Android SDK:
API Levels: 28, 29
Build Tools: 28.0.3, 29.0.0, 29.0.1
System Images: android-28 | Google Play Intel x86 Atom, android-29 | Intel x86 Atom_64
IDEs:
Android Studio: 3.6 AI-192.7142.36.36.6241897
Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild
npmPackages:
react: 16.12.0 => 16.12.0
react-native: 0.61.5 => 0.61.5
npmGlobalPackages:
react-native-cli: 2.0.1
Steps To Reproduce
Render the following on android vs. iOS
const testString = 'sup\u00ADer\u00ADfrag\u00ADilis\u00ADtice\u00ADxpial\u00ADidocious'
return (
<View>
<Text style={{ width: 100 }}>
{testString}
</Text>
</View>
);
Expected Results
Screenshot from iOS
Actual Result
Screenshot from Android
Issue Analytics
- State:
- Created 4 years ago
- Reactions:10
- Comments:15
Top Results From Across the Web
How to implement soft hyphen in Android w/ React Native Text
If you want to use soft hyphen use \u00AD in strings, e.g.: ... I have the same problem and it seems that Android...
Read more >Android soft hyphen,
Android soft hyphen. Description: On android soft-hyphen unicode u00AD is ignored, neither the word break nor the hyphen are displayed correctly.
Read more >History of hyphenation in Android - Cups of Code
Quick overview of handling hyphenation in Android's TextView. ... Note, soft hyphen is ignored in this value, and will not be used as...
Read more >Unicode Character 'SOFT HYPHEN' (U+00AD) - FileFormat.info
Unicode Character 'SOFT HYPHEN' (U+00AD) ; UTF-32 (hex), 0x000000AD (00ad) ; UTF-32 (decimal), 173 ; C/C++/Java source code, "\u00AD" ; Python source code,...
Read more >Hyphens | Android Developers
\u00AD ("soft" hyphen) This character is not rendered visibly; instead, it marks a place where the word can be broken if hyphenation is...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m checking for that as well.
and I don’t change the text again if alreadyHyphenated === true
I know it’s not perfect (yet), but it is a step in the right direction I think. Not it’s just eliminating these quirks. It also sometimes brings the hyphenated word to the next line because the added dash pushes it over the edge. I’ll have to think of a solution for that as well…
https://developer.android.com/reference/android/widget/TextView#setHyphenationFrequency(int)
seems that
setHyphenationFrequency
allows us to use automatic hyphenation