• 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
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Himai Minh
  • Carey Brown
  • salvin francis

How to replace multibyte characters in a string

 
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a japanese string (encoding Shift_Jis).I have to replace a part of this string with another string depending on user input via an HTML form.
I am not able to do this.The String.replace method does not work for non-english characters.I even tried Pattern and Matcher class in java.util.regex package but that too does not work.
I have already set the form attribute as enctype="multiform/form-data".
also in JSP ,I have done <%@ page contentType="text/html;charset=UTF-8"%>.

Is there any way to achieve it?
Please help.It is quite urgent.
 
Marshal
Posts: 71050
291
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hardly a beginner's topic.

Moving.
 
Sheriff
Posts: 22041
113
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please Ease Up.
 
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Regexp work fine for non-ASCII strings. Note that Java strings are in Unicode, not JIS, so you can use classes like \p{Lu} and \p{L}. See the section on Unicode support in the Pattern javadocs.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think replace(CharSequence target, CharSequence replacement) <since jdk 1.5> or replaceAll(String regex,String replacement) <since jdk 1.4> can do the job.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic