Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

validating multibyte characters

 
anagha patankar
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This blog entry is also relevant on the topic of counting characters.
[ May 29, 2007: Message edited by: Ulf Dittmer ]
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic