Automatically align text in UILabel according to text language

后端 未结 5 569
-上瘾入骨i
-上瘾入骨i 2021-02-04 19:59

I\'m interested in setting some text into a UILabel, and depending on the directionality of the language (e.g., Hebrew - right-to-left [RTL], English - left-to-righ

5条回答
  •  感情败类
    2021-02-04 20:45

    I think the scan loop in -getBaseDirection should be for self.length times instead of utf32data.length in the accepted answer.

    utf32data.length is the size in bytes while sizeof(UTF32Char) == 4, which would result in an overrun.

    In action, the current code sporadically returns false positives for identical input, depending on what it overruns onto (maybe it'll segfault on a sufficiently bad day). Everything else seems to be working perfectly with the fix.

提交回复
热议问题