On 2025-05-18 12:23 p.m., John Yeung wrote:
...
But for fields with a fixed number of characters, how does the database
handle the possibility of variable number of bytes? If I have a
CHARACTER(10) field, do I just get 10 bytes, and if some characters need
more than 1 byte, then I effectively get fewer than 10 characters? Does it
just truncate after 10 bytes, even if it's in the middle of a character?


A CHARACTER(10) does get 10 bytes, possibly fewer characters. The length-prefix for a VARCHAR field is measured in bytes.

A rule of thumb I saw once for converting an EBCDIC database field to UTF-8 is to triple the length just to be sure.

About whether the last character would be truncated, RPG ignores UTF-8 character sizes by default, so it might truncate the final character.

See the discussion of CHARCOUNT NATURAL in the manual to see how to get RPG to handle UTF-8 correctly.

I'm not expert enough to say how database handles the different character sizes for UTF-8.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

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

This mailing list archive is Copyright 1997-2025 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.