• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Differentiate between english domains and international  RSS feed

 
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
 
author
Posts: 23832
140
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
 
Rancher
Posts: 42974
76
  • 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!