Click here to Skip to main content
15,742,180 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi every one

Is there a simple way to split a Farsi String like "سلام" into it's characters.
I want to have stand alone characters not for example "ل".
Richard MacCutchan 30-Jun-13 3:37am    
It should be the same as any type of string; a string is simply an array of charcters.
Maciej Los 30-Jun-13 4:53am    
Good answer, my virtual 5!
cigwork 30-Jun-13 5:11am    
Yes, but the multi-byte character encoding schemes used to handle many non-Latin alphabets mean that there isn't necessarily a 1:1 match between a byte (char) and what's painted on the monitor.
Richard MacCutchan 30-Jun-13 7:31am    
True, perhaps it would be necessary to use the Normalize method first. I'm susre a Google search would yield some suggestions.

1 solution

Checking MSDN it looks as though you'll need to use System.Globalization.StringInfo.ParseCombiningCharacters and StringInfo.TextElementEnumerator
There's some example code here:

Noddy example:

StringBuilder b = new StringBuilder();
StringInfo si = new StringInfo("αβγδεζηθικλμνξοπρστυφχψωέϊή");

TextElementEnumerator iter = StringInfo.GetTextElementEnumerator("αβγδεζηθικλμνξοπρστυφχψωέϊή");
while (iter.MoveNext()) {
  b.Append(iter.GetTextElement()).Append(" ");

Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900