Shaheen Zahedi
Shaheen Zahedi

Reputation: 1266

Display Arabic/Persian letter/character separately in Java?

I want to properly separate each letter/character of an Arabic/Persian word, in an isolated letter/character without changing it's face, and persisting their medial/initial/isolated/final form,

Here's an example:

Regular segmentation:

بابا ====>  ب ا ب ا

شاهین ====> ش ا ه ی ن

Desired segmentation:

بابا ====> بـ ـابـ ـا

شاهین ====> شـ ـاهـ یـ ـن

Upvotes: 4

Views: 490

Answers (1)

aran
aran

Reputation: 11860

You could use Normalizer to achieve this. Take a look here for more info.

Something like:

 String segmented = Normalizer.normalize(input, Form.NFKD).replaceAll("\\p{M}", "");

Upvotes: 1

Related Questions