aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes string delimiter 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 » Engineering » HTML, CSS and JavaScript
Bookmark "string delimiter" Watch "string delimiter" New topic
Author

string delimiter

Kicky San
Greenhorn

Joined: Aug 24, 2005
Posts: 18
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.


Cheers,<br />KicKy
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
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 ]

Rahul Bhattacharjee
LinkedIn - Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: string delimiter