please run the following program. It tries to Convert a sting from UNICODE to my local codepage “win-1252”. One of the Unicode-Characters (i.e. UH’010D’ = C+caron) is non-existant in my local codepage. So a NAT3413 occurs.
define data local
01 #u10 (U10) init <UH'00410042010D0044'> /* A B C+caron D
01 #a10 (A10)
01 #usr2030
02 #usr2030-ERR-PARM (A253/1:9)
02 #usr2030-OCC (N01) /* Number of occurences
02 #usr2030-RESPONSECODE (N04) /* Error code, not used
end-define
on error
if *ERROR-NR = 3413
write 'Codepage-Transformation error'
write '=' #a10 (EM=H(10))
callnat 'USR2030N' #usr2030
write '=' #usr2030-OCC
write '=' #usr2030-ERR-PARM(1) (AL=70)
end-if
end-error
write '=' *CODEPAGE
#a10 := #u10 /* unicode --> win-1252 /* NAT3413 here
end
The documentation of NAT3414 says:
So I would expect to get the “bad” character in :1:… But it doesn’t work.
In order to avoid runtime errors in case of conversion errors, I mostly use the
‘Move encoded’… (e.g. a binary xml input with data) to … (alphanumeric variable) 'giving #move-encoded-error" (#move-encoded-error is my variable for error code).
If #move-encoded-error is 0, everything is ok; if not, I know I have to handle the input in another way and can’t just convert it into a string in the default codepage.
But I also would like to know more exactly which character causes the problem.