Zero-width space with special characters
Asked Answered
R

0

10

Interesting problem here, wondering if anyone has come across it.

I am building an Android app that has some special characters as text (mainly Japanese characters) and our designers want some soft returns strategically placed, incase the text needs to wrap due to width limitations on smaller devices.

The problem is that since the text is essentially Japanese, there are no spaces between words.

I know we can use \u200b as a zero-width space resulting in a string like this:

abcdef\u200bghijklmnop

appearing like this when there is enough room:

abcdefghijklmnop

and like this if it needs to wrap:

abcdef
ghijklmnop

The problem is that if instead of standard English characters, we use Japanese characters it doesn't seem to work. We don't get soft line breaks at all. It instead always breaks right where it runs out of space regardless of where we put the \u200b

ヘルプヘルプ\u200bヘルプヘルプ

results in:

ヘルプヘルプヘルプヘ
ルプ

Has anyone dealt with this before or have any ideas on how to solve this?

Ravishing answered 8/1, 2016 at 15:15 Comment(1)
Are you using a custom font?Drin

© 2022 - 2024 — McMap. All rights reserved.