Kbase P141110: Error 142 when copying characters from a LONGCHAR to a CHARACTER variable
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  25/10/2010 |
|
Status: Unverified
SYMPTOM(s):
Error 142 when copying characters from a LONGCHAR to a CHARACTER variable
** Unable to update <filename> Field. (142)
Data is being returned from an OLE object to a LONGCHAR. A SUBSTRING of the LONGCHAR data is being assigned to a character variable and this results in the 142 error.
Error converting LONGCHAR variable to cpinternal for comparison. (11687)
Could not convert LONGCHAR to cpinternal. (11669)
The LONGCHAR code page is UTF-8.
DEF VAR Redemption_Object AS COM-HANDLE NO-UNDO.
DEF VAR vLongString AS LONGCHAR NO-UNDO.
DEF VAR vshortString AS CHARACTER NO-UNDO.
CREATE "Redemption.SafeMailItem" Redemption_Object NO-ERROR.
/* other OLE code here to fetch the email*/
Longstring = Redemption_Object:HTMLBody NO-ERROR. /* this works */
vshortstring = SUBSTRING( vLongstring, 1, 30000 ) . /* error 142 occurs here unless cpinternal = "UTF-8" */
Error 142 is displayed unless -cpinternal is UTF-8.
FACT(s) (Environment):
All Supported Operating Systems
OpenEdge 10.1x
CAUSE:
The cause of the problem is because the LONGCHAR contains data that is not supported in the session codepage. For example the LONGCHAR may contain Central European or Cyrillic data but the session is using a Western European codepage. So the data from the incompatible region cannot be converted without corruption.
Most character functions (e.g. INDEX, REPLACE and SUBSTRING) when used with LONGCHAR datatypes must convert the LONGCHAR to the -cpinternal codepage before performing their designed functionality. The function return value will then be converted back from -cpinternal to the LONGCHAR code page.
FIX:
This is expected behavior. The product is behaving as designed.