I have a string, how can i detect whether it is Unicode or not. Basically my string is like پاکستان is our country PHP: If i double click on پاکستان the response should be Unicode for rest English text it shouldn't be Unicode text.
Your mind is translate پاکستان to english? If not you can see here for detect unicode http://utf8checker.codeplex.com/ Hope this help
Although your terminology is not exactly correct, if I understand your question correctly, you want to detect parts of a string that can be written in certain encoding (ASCII or maybe Latin-1) and parts that can not be written in certain encoding. If this is what you want then try to convert your text to the particular encoding - say ASCII and then compare it back with your string. private static bool IsAscii(string Part) { byte[] asciiBytes = Encoding.ASCII.GetBytes(Part); string partAscii = Encoding.ASCII.GetString(asciiBytes); return Part == partAscii; } string part = "test 1"; Console.WriteLine("{0} {1} ASCII", part, IsAscii(part) ? "is" : "isn't"); part = "čšýáířřží"; Console.WriteLine("{0} {1} ASCII", part, IsAscii(part) ? "is" : "isn't"); part = "پاکستان"; Console.WriteLine("{0} {1} ASCII", part, IsAscii(part) ? "is" : "isn't"); part = "is our country"; Console.WriteLine("{0} {1} ASCII", part, IsAscii(part) ? "is" : "isn't"); Code (markup): Now, for the first string and the last string, in the example above, the IsAscii function returns true. For the second and third, it returns false.