• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Differentiate between english domains and international

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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's weird that we cook bacon and bake cookies. Eat this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic