I need to copy a txt file to as400.
If I do CPYFRMPCD or CPYFRMSTMF the accented characters move the length of the file 1 or 2 positions.
What can I do to avoid this?
Thank you
copy file txt
Re: copy file txt
We need to know more about what you want to do.
Where is the txt file you want to copy? On the IBM i or on a Windows computer? (I assume you are using Windows.)
What is the character encoding (a number on IBM i called CCSID) of the txt file? Is it Unicode (UTF-8)? Or is it ASCII? If it is ASCII, which nationality?
You mention CPYFRMPCD - for that, your file has to be in /QDLS, and you have to copy the file to a physical file. And the text file is assumed to be ASCII. You need to use the TRNTBL parameter to tell how to convert the text - *DFT might work, it uses the national language of your system.
Here is a link with more information about CPYFRMPCD, if you think you have to use that. But IBM recommends that we do not use QDLS - it is very old technology and is very slow. https://www.ibm.com/support/pages/data- ... n-commands
If the text file is on a PC, I suggest maybe using FTP - you will probably need to know which character encoding you use, if you are in a country other than the US.
That is all I can think of - we need to know more details from you t help.
Where is the txt file you want to copy? On the IBM i or on a Windows computer? (I assume you are using Windows.)
What is the character encoding (a number on IBM i called CCSID) of the txt file? Is it Unicode (UTF-8)? Or is it ASCII? If it is ASCII, which nationality?
You mention CPYFRMPCD - for that, your file has to be in /QDLS, and you have to copy the file to a physical file. And the text file is assumed to be ASCII. You need to use the TRNTBL parameter to tell how to convert the text - *DFT might work, it uses the national language of your system.
Here is a link with more information about CPYFRMPCD, if you think you have to use that. But IBM recommends that we do not use QDLS - it is very old technology and is very slow. https://www.ibm.com/support/pages/data- ... n-commands
If the text file is on a PC, I suggest maybe using FTP - you will probably need to know which character encoding you use, if you are in a country other than the US.
That is all I can think of - we need to know more details from you t help.
Re: copy file txt
Thanks for the reply.
The problem was the CCSID.
I solved it like this:
CPYFRMSTMF FROMSTMF('/dir/file.txt')
TOMBR('/QSYS.LIB/LIBR.LIB/FILEX.FILE/FILEX.MBR')
MBROPT(*REPLACE)
STMFCCSID(1208)
Thanks again
The problem was the CCSID.
I solved it like this:
CPYFRMSTMF FROMSTMF('/dir/file.txt')
TOMBR('/QSYS.LIB/LIBR.LIB/FILEX.FILE/FILEX.MBR')
MBROPT(*REPLACE)
STMFCCSID(1208)
Thanks again
-
- Site Admin
- Posts: 763
- Joined: Sun Jul 04, 2021 5:12 am
Re: copy file txt
Sounds like your file has been marked with the wrong CCSID for the data that's in it. For example, maybe the file is set as CCSID 819 (iso-8859-1) when the reality is that the data is in 1208 (UTF-8).
Since characters beyond the basic ones use multiple bytes in UTF-8 (but don't in iso-8859-1) the system is misinterpreting them, thinking each byte is a separate character (because it thinks the file is iso-8859-1) when it's really multiple bytes for one character (utf-8)
That would explain why adding STMFCCSID(1208) would solve the problem. Of course the default value of STMFCCSID(*STMF) would've worked fine if the file had been marked correctly as 1208 to start with.
Please drop the CPYFRMPCD command and the term "as400" from your usage. They are at least 24 years out of date. (CPYFRMPCD is more like 32 years out of date.)
Since characters beyond the basic ones use multiple bytes in UTF-8 (but don't in iso-8859-1) the system is misinterpreting them, thinking each byte is a separate character (because it thinks the file is iso-8859-1) when it's really multiple bytes for one character (utf-8)
That would explain why adding STMFCCSID(1208) would solve the problem. Of course the default value of STMFCCSID(*STMF) would've worked fine if the file had been marked correctly as 1208 to start with.
Please drop the CPYFRMPCD command and the term "as400" from your usage. They are at least 24 years out of date. (CPYFRMPCD is more like 32 years out of date.)