Kbase P129928: String function works in COLUMN units
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  3/27/2008 |
|
Status: Unverified
FACT(s) (Environment):
All Supported Operating Systems
Progress 8.x
Progress 9.x
OpenEdge 10.x
SYMPTOM(s):
String function works in COLUMN units
String function with FORMAT option works in COLUMN units not CHARACTER units.
STRING function being used with multibyte extended characters.
Using multi byte client started cpinternal set to Japanese, or UTF-8.
CAUSE:
This is expected behavior.
FIX:
When you specify the FORMAT option with the STRING function, the STRING function uses COLUMN units. For example, run the following code in a Japanese client started with -cpinternal shift-jis, -cpstream shift-jis, -cpcoll basic:
DEFINE VARIABLE val AS CHARACTER NO-UNDO.
DEFINE VARIABLE truc AS CHARACTER NO-UNDO.
val = FILL(chr(37559,"SHIFT-JIS","SHIFT-JIS"),45).
truc = STRING(val,"x(50)").
MESSAGE
"CHAR : " LENGTH(val,"CHARACTER") SKIP
"COL : " LENGTH(val,"COLUMN") SKIP
"RAW : " LENGTH(val,"RAW") SKIP
"---------------------------------" SKIP
"CHAR : " LENGTH(truc,"CHARACTER") SKIP
"COL : " LENGTH(truc,"COLUMN") SKIP
"RAW : " LENGTH(truc,"RAW") SKIP
"Byte49 : " ASC(SUBSTRING(truc,49,1,"RAW"),"1252","1252") SKIP
"Byte50 : " ASC(SUBSTRING(truc,50,1,"RAW"),"1252","1252") SKIP
"Byte51 : " ASC(SUBSTRING(truc,51,1,"RAW"),"1252","1252") SKIP
truc SKIP
asc(SUBSTRING(truc,1,1))
VIEW-AS ALERT-BOX INFO BUTTONS OK.
In the above example, specifying "X(50)" with the STRING function reserves 50 spaces for the string but since this particular Japanese character is 2 bytes (92,B7 - SHIFT-JIS) more than 50 spaces is needed to store 45 characters. Subsequently the string is truncated to 25 characters, but uses the available 50 columns.