This content has been marked as final. Show 7 replies
Sorry the amp;# missed out.
I have a J2EE application and currently we are storing the Unicode data in amp;#xxx; format.
The browser can display this properly but the java swing application cannot. So I need to convert this to \uxxxx format.
Is it advisable to store the data in the d/b in the \uxxxx format or amp;#xxx; format ? Advantages ? Disadvantages ?
The database is setup for UTF-8.
I suggest you store the data in the database in its native format.
Most databases support unicode (16-bit) characters by default. WHich database are you using?
I am using Oracle.
Could you please elaborate on the "native format" ?
If you use JDBC to send data to the database, it will take care of any necessary transformations. Just send the data as a String and, assuming your database is set up for Unicode properly, you will safely store a Unicode string. There's no need to use escape sequences or HTML entities. In fact, these are a bad thing because the database won't know they are Unicode. It will just see a sequence of ASCII characters. I recommend reading the JDBC tutorial.
I agree with the general statement in this draft FAQ from w3.org:
It is almost always preferable to use an encoding that allows you to >represent the characters in their normal form, rather than using character >entities or NCRs.( http://www.w3.org/International/questions/qa-escapes )
So I would say the choice should not be between storing the characters as NCRs or Unicode escape sequences, but rather between storing them as normal UTF-8 or escape sequences.
I would normally recommend storing the characters simply as UTF-8 encoded, mainly because that will ensure that you don't have to perform conversion if you have to interface with other DBs or with other middleware. So I would recommend implementing a native2ascii conversion on the characters when they are extracted (if that is possible).
I am using JDBC API to store data in the database and it is storing in native format. I have no problem to retrieve it from base using the JDBC API. For me as part of master data, i need to execute some SQL statements. Is there any way to insert native format to database using insert query and that should also be easily convertible by JDBC as in case of other native format data stored from application.
Please don't post to years old threads. Start your own threads instead of hijacking others.