How to implement soft hyphen in Android w/ React Native Text

2.9k views Asked by At
<Text>
Aufmerksamkeits{'\u00AD'}defizit
</Text>

This leads iOS to

Aufmerksamkeits-
defizit

But on Android to

Aufmerksamkeitsd
efizit

So it seems that Android ignores the given soft hyphen. How can I make this work on Android as well?

2

There are 2 answers

2
APTower On

If you want to use soft hyphen use \u00AD in strings, e.g.:

<string name="einzelfahrt_name">Einzelfahrrad\u00ADkarte</string>

In order to make this working though, in your TextView, you have to add:

android:hyphenationFrequency="full"
0
Bruno On

I have the same problem and it seems that Android ignores soft hyphens.

The only workaround I could think of is, only on Android, to replace the \u00AD with \u200B. It's known as zero-width-space, and it would properly break the words where expected, although it would not show any hyphenation character. You would end up with:

Aufmerksamkeits
defizit

Not the perfect solution, but at least it will not break words at random positions.