× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



... that may or may not include double byte.

After going back and forth on a routine to trim a Unicode string to a length that will fit into a fixed length database field, I came up with this routine ...

http://code.midrange.com/9c0db304e1.html

You call it with a Unicode string, the field size in question, and the CCSID of the field, and it will return a Unicode string that has been trimmed to a length that will completely fit in the database field. Alternatively you can call the method with an AS400Text field object and it will get the length & CCISD automatically.

Basically, the routine uses the CharConverter class to convert the Unicode data to double byte, trims the double byte to fit into the field length, and then checks to see if the so/si pairs are balanced. If they are not balanced it balances them ... then converts the trimmed value back to Unicode .

It requires the Apache Commons Language utilities. You'll probably want to substitute your own logger function, or have it throw the encoding exception.

david



As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.