aspose file tools*
The moose likes Servlets and the fly likes validating multibyte characters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "validating multibyte characters " Watch "validating multibyte characters " New topic
Author

validating multibyte characters

anagha patankar
Ranch Hand

Joined: Dec 26, 2005
Posts: 53
Hello ,
Facing an issue :

Have a HTML form with a single textbox .
This data needs to be inserted into a database table ( max field length = 20 varchar2(20))

Once the form is submitted - I am checking length of the submitted data and if length is > 20 give a error message.

This works for english characters - but if I enter multibyte characters
then the Java code that is checking length seems to pass .

However at oracle end - throws an error
and when I check using the function lengthb available with oracle
it shows the length of the data to be much more than 20

Can someone help me with checking length of data ( multibyte or otherwise )
in such a scenario.

Thanks in advance ,
-Anagha
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
What is the encoding of your database and your application/JVM ?

I would take it in this way.First of all I would like to normalize the encodings.If the encoding followed by application is different then that of the database then I would like to make those same before making any comparison.


Rahul Bhattacharjee
LinkedIn - Blog
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42289
    
  64
This blog entry is also relevant on the topic of counting characters.
[ May 29, 2007: Message edited by: Ulf Dittmer ]

Ping & DNS - my free Android networking tools app
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Originally posted by Ulf Dittmer:
This blog entry is also relevant on the topic of counting characters.


This blog entry is very interesting and informative , but it explains about supplementary character manipulation using JDK - 1.5.

If the encoding of the application and database is different then also there would be error , even if we find that the number of characters is same in application as defined for the database column.
 
Don't get me started about those stupid light bulbs.
 
subject: validating multibyte characters