• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

string delimiter

 
Kicky San
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,
I have got a question on string delimiters.

I am working on a java script which takes user input from two text areas and sends it to a servlet.
I would like to concatenate as a single string in the javascript and send it to the servlet through POST method.
The string values entered can be of any language. In servlet, the strings are converted to UTF-8 format. Then I pass the whole string to a database procedure where it is splitted.

What delimiter is the best? (I thought of using | and ^) - but am scared about the encoding part of the whole string.Will there be any problems in using these characters? For example can two japanese/chinese/spanish strings be concatenated with these delimiters without any problem?

Any help would be highly appreciated.

Thanks !

PS: I dont have access to the servlet code. I am supposed to change only the javascript/ database procedure.
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Kicky San:
The string values entered can be of any language. In servlet, the strings are converted to UTF-8 format.



Before converting the data , that is coming from client , how are you making sure that the client is using UTF-8 encoding as character encoding for sending the data?

Only this is the thing that you need to take care about. Delimeter doesnot matter.But prefer a symbol for delimeter , rather than character or number.Like , if # is not likely a part of your data then , might consider this as delimeter.

From Servlet 2.3 sepcification.

Currently, many browsers do not send a char encoding qualifier with the Content-
Type header, leaving open the determination of the character encoding for reading
HTTP requests. The default encoding of a request the container uses to create the
request reader and parse POST data must be �ISO-8859-1� if none has been
specified by the client request.


You can use the following piece of code for deciding upon the encoding.

String encoding = request.getCharacterEncoding();

if encoding == null , use ISO-8859-1 as encoding for the incoming data , or else using the encoding which we got using

String encoding = request.getCharacterEncoding();

Hope this helps,
[ December 06, 2006: Message edited by: Rahul Bhattacharjee ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic