Hello Mehta.....am soo pleased with your solution but not yet fully pleased. Now if i get this block of text "RAJAB ISHAQ ZEMBE رجب إسحاق زيمبي", i get ????????? marks i think they are representing the Arabic letters, how can i have my arabic letters returned
and printed out just the way they look in the unsplit string
feiyim
Member
165 Points
99 Posts
Separate a string into two string with differenct cultures
Aug 03, 2011 11:16 AM|LINK
Hello, i am having this piece of text "SHARIF SIRAJ MUWONGE شريف سراج موونغي"
I would like to split the above text in that the English name is separate from the Arabic name
mehta.rahuli...
Contributor
2210 Points
729 Posts
Re: Separate a string into two string with differenct cultures
Aug 03, 2011 11:29 AM|LINK
u can make ascii value comparision..getting me?
loop through and check its ascii equivalent...
MCAD
Contributor Award 2011
feiyim
Member
165 Points
99 Posts
Re: Separate a string into two string with differenct cultures
Aug 03, 2011 12:16 PM|LINK
here is what am doin but still aint geting the required result
static void Main(string[] args) { const String str = "ABDUL RAHUM عبد الرحيم"; int i = 0; foreach (byte b in Encoding.UTF8.GetBytes(str.ToCharArray())) { if (b < 32 && b > 90) { //Console.Write(b + "\n"); str.Insert(i - 1, "_ "); break; } i++; } ArrayList texts = new ArrayList(str.Split('_')); foreach (String V in texts) { Console.Write(V + "\n"); } Console.ReadLine(); }mehta.rahuli...
Contributor
2210 Points
729 Posts
Re: Separate a string into two string with differenct cultures
Aug 03, 2011 12:26 PM|LINK
Convert.ToChar( myvar.substr( 1, 1) ) == 65
dont convert to byte and try...
http://www.dotnetperls.com/ascii-table
MCAD
Contributor Award 2011
mehta.rahuli...
Contributor
2210 Points
729 Posts
Re: Separate a string into two string with differenct cultures
Aug 03, 2011 12:29 PM|LINK
const String str = "عبد الرحيم"; int i = 0; foreach (byte b in Encoding.UTF8.GetBytes(str.ToCharArray())) { if (b < 32 && b > 90) { //Console.Write(b + "\n"); str.Insert(i - 1, "_ "); break; } i++; }MCAD
Contributor Award 2011
feiyim
Member
165 Points
99 Posts
Re: Separate a string into two string with differenct cultures
Aug 03, 2011 12:37 PM|LINK
My new improved code but still aint getting it right.....can someone please gimmi a code
static void Main(string[] args) { const String str = "A ب"; int i = 0; foreach (byte b in Encoding.UTF8.GetBytes(str.ToCharArray())) { if (b > 122) { str.Insert(i - 1, "_" + " "); break; } i++; } ArrayList texts = new ArrayList(str.Split('_')); foreach (String V in texts) { Console.Write(V + "\n"); } Console.ReadLine(); }mehta.rahuli...
Contributor
2210 Points
729 Posts
Re: Separate a string into two string with differenct cultures
Aug 03, 2011 02:01 PM|LINK
this should help you public static bool IsEnglish(string input) { const string Numeric = "0123456789"; const string Alpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; const string Punctuation = " .,-=+()[]{}¬"; const string Special = "\"\\\t\r\n"; const string Lookup = Numeric + Alpha + Punctuation + Special; input = "" + input; for (int i = 0; i < input.Length; i++) { if (!Lookup.Contains(input[i].ToString())) { return false; } } return true; }MCAD
Contributor Award 2011
mehta.rahuli...
Contributor
2210 Points
729 Posts
Re: Separate a string into two string with differenct cultures
Aug 03, 2011 03:08 PM|LINK
finally i got it...sorry for giving you solution without trying
string input = "A ب;"; string spe = ""; foreach (char character in input.ToCharArray()) { if (HasArabicCharacters(character.ToString())) spe = character.ToString(); }static bool HasArabicCharacters(string text) { Regex regex = new Regex( "[\u0600-\u06ff]|[\u0750-\u077f]|[\ufb50-\ufc3f]|[\ufe70-\ufefc]"); return regex.IsMatch(text); }MCAD
Contributor Award 2011
feiyim
Member
165 Points
99 Posts
Re: Separate a string into two string with differenct cultures
Aug 03, 2011 03:25 PM|LINK
Hello Mehta.....am soo pleased with your solution but not yet fully pleased. Now if i get this block of text "RAJAB ISHAQ ZEMBE رجب إسحاق زيمبي", i get ????????? marks i think they are representing the Arabic letters, how can i have my arabic letters returned and printed out just the way they look in the unsplit string
mehta.rahuli...
Contributor
2210 Points
729 Posts
Re: Separate a string into two string with differenct cultures
Aug 03, 2011 04:04 PM|LINK
i installed a arabic font as well on my machine..but it is working on my machine...
not sure because i installed font
MCAD
Contributor Award 2011