Consultor Eletrônico



Kbase P20688: Field alignment is incorrect when printing using Thai fonts
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   4/8/2009
Status: Verified

SYMPTOM(s):

Field alignment is incorrect when printing using Thai fonts

Character field width is different than the given FORMAT

FACT(s) (Environment):

Windows
Progress 8.x
Progress 9.x
OpenEdge 10.0x
OpenEdge 10.1A
OpenEdge 10.1B
OpenEdge Category: Language (4GL/ABL)

CAUSE:

Bug# OE00085493

CAUSE:

Thai characters can use 1,2,3 bytes for each visible character and is causing the field format to be calculated incorrectly.

FIX:

Upgrade to 10.0B04 or later
OR
Upgrade to 10.1A01 or later
OR
Upgrade to 10.1B or later
Workaround:

Modify your Progress 4GL code and use the following 4GL function. The first parameter passed to the function is the field containing the value, and the second is the visual width of the field that you want.

FUNCTION thai-fmt RETURNS CHAR
(INPUT str AS CHAR,
INPUT wid AS INT).

DEF VAR i AS INT.
DEF VAR cols AS INT.
DEF VAR fmt AS CHAR.
DEF VAR tempval AS CHAR.
DEF VAR combining AS CHAR INIT
'~321~324~325~326~327~330~331~332~347~350~351~352~353~354~355'.
DO i = 1 TO LENGTH(str).
IF INDEX (combining, SUBSTRING(str, i, 1) ) = 0 THEN DO:
cols = cols + 1.
END.
IF cols = wid + 1 THEN
LEAVE.
ELSE
tempval = tempval + SUBSTRING(str, i, 1).
END.

IF cols < wid THEN DO:
fmt = FILL('x', wid - cols).
RETURN str + STRING( " ", fmt).
END.
ELSE
RETURN (tempval).

END FUNCTION.


/* Usage: */
DEF VAR custname AS CHAR INITIAL "thai characters here".
DEF VAR logvar AS LOG.
DEF STREAM s1.

OUTPUT STREAM s1 TO c:\temp\tempfile.txt.
PUT STREAM s1 UNFORMATTED thai-fmt(custname,20) SKIP(1).

RUN adecomm/_osprint.p (INPUT ? , INPUT "tempfile.txt" ,
INPUT 8 , INPUT 12 , INPUT 0,
INPUT 0 , OUTPUT logVar).