question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android ignores unicode soft hyphen (u00AD)

See original GitHub issue

Description: 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 IMG_DB2643BEA609-1

Actual Result

Screenshot from Android IMG_25E611476E59-1

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:10
  • Comments:15

github_iconTop GitHub Comments

3reactions
lennartdemeijcommented, Jun 16, 2020

I’m checking for that as well.

if (line.text.substr(line.text.length - 2) === "- ") {
 alreadyHyphenated = true;
}

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…

1reaction
fabriziobertoglio1987commented, May 19, 2021

https://developer.android.com/reference/android/widget/TextView#setHyphenationFrequency(int)

setHyphenationFrequency Sets the frequency of automatic hyphenation to use when determining word breaks.

seems that setHyphenationFrequency allows us to use automatic hyphenation

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found