[Project_owners] Determining Strings are in English

matthew at mjwilson.demon.co.uk matthew at mjwilson.demon.co.uk
Mon Feb 21 08:44:21 EST 2005


brintoul at sbcglobal.net wrote:
> I have an array of strings that I'd like to display to the user only 
> those that are in English.  Does anyone know a nice routine to determine 
> if a Unicode string is English?

Do you mean "contains only English characters"? Then you could use a regular expression, something like

   /^[ -~]*$/.exec (testString)

which tests for all ASCII characters between space and ~ (it would exclude TAB and newlines though).

This might wrongly exclude a few English words which are spelt with accents though.

Matthew



More information about the Project_owners mailing list