Question to NAT3413

Hello all,

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.

The output of the program above is as follows:

CODEPAGE: windows-1252
Codepage-Transformation error
#A10: 41421A44202020202020
#USR2030-OCC:  0
#USR2030-ERR-PARM:

Any ideas? My Natural-Version is 6.3.9@Solaris.

Regards

Matthias

Hello Matthias,

I experienced the same; we are on Nat 6.3.12 .

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.

Kind regards
Eva

Hello Eva Grill,

thanks for your answer.
Of course we can do a workaround like the following:

define data local
01 #u10 (U10) init <UH'00410042010D010E'> /* A B C+caron D+caron
01 #a10 (A10)
01 #u10b (U10)
01 #u1a (U1)
01 #u1b (U1)
01 #i4  (I4)
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)
    #u10b:= #a10 /* back to unicode to find out bad chars
    for #i4 = 1 to 10
      #u1a:= substr(#u10,#i4,1)
      #u1b:= substr(#u10b,#i4,1)
      if #u1a ne #u1b
        write 'bad char' #u1a (EM=HH) 'on pos' #i4
      end-if
    end-for
  end-if
end-error
write '=' *CODEPAGE
#a10 := #u10  /* unicode --> win-1252 /* NAT3413 here
end

But if I understand the documentation correctly I think Natural should do this job for me…

Matthias

Hi Matthias,

I think you’re right. I’ve tried to run your example on z/OS and the result is:

Page      1                                                  12-12-13  14:05:11
                                                                               
CODEPAGE: IBM01143 
Codepage-Transformation error 
A10: C1C23FC4404040404040
USR2030-OCC:  1
USR2030-ERR-PARM:
010D


NAT3413 Conversion error, at least 1 code point not translated. H'010D'

I suggest you open a support request for Open Systems.

Best regards,
Mogens

Hello Mogens,

thanks for trying it out on your z/OS.

I’ve just opened up a support request…

Matthias