[opencms-dev] How to Escape Unicode String in Properties of Files

Philip Kuegler mailinglists at pcom.at
Tue Nov 25 13:49:38 CET 2008


Hi,

might be a little bit far from clean programming, but:

Oracle does support triggers and string manipulation in PL/SQL scripts. 
Did you give it a try to manipulate (encode) the string on store or 
update and decode it on read?

Triggers: 
http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/triggers.htm

br,
Philip




Ly The Thanh wrote:
> Hi,
>
> I'm using OpenCms 7.0.5, Oracle10g, OC4J10g.
> content of the site is on unicode (like that: OpenCms rất tuyệt vời!) 
>
> In my database the content of xml file is ok (as using CLOB datatype), 
> but the properties is not store correctly (as VARCHAR2 encoding in my company db is US7ASCII, and not allow to change to AL32UTF8).
>
> so to store the properties correctly, I thing there are 2 way to do this:
>
> 1. I may have to change VARCHAR2 to NVARCHAR2 (as NVARCHAR2 in my company db is AL16UTF16). I haven't do this because I have to setup OC again.
>
> 2. I need to escape unicode character and convert to NCR code when opencms save the properties. with a function like this:
>
> // Unicode to NCM, which will convert a String like this "OpenCms rất tuyệt vời" --> "OpenCms rất tuyệt vời"
> public static String escapeUnicodeString(String str, boolean escapeAscii) {
>         String ostr = new String();
>         for (int i = 0; i < str.length(); i++) {
>             char ch = str.charAt(i);
>             if (!escapeAscii && ((ch >= 0x0020) && (ch <= 0x007e)))
>                 ostr += ch;
>             else {
>                 ostr += "&#";
>                 String hex = Integer.toString(str.charAt(i) & 0xFFFF);
>                 if (hex.length() == 2)
>                     ostr += "00";
>                 ostr += hex;
>                 ostr += ";";
>             }
>         }
>         return (ostr);
>     }
>
> But I don't known how to apply these change in opencms, which class I have to change.
>
> Please help me how to do this.
>
> Thanks you in advanced!
>
>
>
>       
>
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/mailman/listinfo/opencms-dev




More information about the opencms-dev mailing list