• Post Reply Bookmark Topic Watch Topic
  • New Topic

Differentiate between english domains and international  RSS feed

 
Gilbert johnson
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

what is the best way to distinguish between an english domain and a domain that contains foreign characters

eg:
yahoo.com - contains English characters
二次核试验.com.cn - contains foreign characters

Thanks in advance
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, if you are just checking characters, I guess you can just check if the characters are letters or numbers. Or you can just check if it is in the printable ascii range, which should be from a value of 32 to 127.

Henry
 
Gilbert johnson
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply Henry.
I did'n think of that approach. I was trying to use the URLEncoder's encode method but that did'nt work for some cases.

Regarding your approach...when the user enters some foreign characters in the browser like
核试

When I read the input and print the String - it prints as
#&3864;#&1444; (something like this)

So I'm supposed to convert each of these characters into ASCII and see if they are in the range between 32 and 127.

So how would I convert a String like "#&3864;" to ASCII

Thanks again
 
Gilbert johnson
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well I still havent found the solution.

The only hack I can come up with is to check if the string contains this pattern "&#" - then to mark it as International.

But I dont think its a good solution.

Any help will be appreciated.
Thanks
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello "gubloo johnson"-

You've been around JavaRanch long enough to know that we have a policy on screen names. Basically, it must consist of a first name, a space, and a last name, and not be obviously fictitious. Since yours does not conform with it, please take a moment to change it, which you can do right here.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!