Forum Post: RE: Code page validation

  • Thread starter Thread starter tbergman
  • Start date Start date
Status
Not open for further replies.
T

tbergman

Guest
Hi Mike, Here's a method we use to make sure the characters can be converted to Windows 1252. METHOD PUBLIC STATIC LOGICAL is1252( pChar AS CHARACTER ): DEFINE VARIABLE vResult AS LOGICAL NO-UNDO. /* No need to check if our session is 1252. This is done so this code will never fail during our transition to the UTF-8 client */ IF SESSION:CPINTERNAL EQ "1252" THEN RETURN TRUE. /* The logic here is using the fact that convert-codepage will turn characters that can't be converted into question marks. If the number of question marks changes, then something was not convertible */ IF NUM-ENTRIES(pChar,"?") NE NUM-ENTRIES (CODEPAGE-CONVERT(pChar,"1252"),"?") THEN RETURN FALSE. ELSE RETURN TRUE. END METHOD.

Continue reading...
 
Status
Not open for further replies.
Back
Top