Saving text file to ISeries IFS being converted from ASCII to?

Question for anyone. I am using a LotusScript agent to save some Base64 encoded text in a RichText file to a .txt file on the server. I’m then taking the .txt file and decoding it to an image file, usually either .jpg or .gif, then attaching that file to a document.

When I do this on a domino server running on a Windows box it works fine. When I run this agent on a domino server running on an AS/400 / ISeries box it attaches images that aren’t images anymore.

I’ve tracked the problem to when I read the text from the Rich Text field and save it to the .txt file on the ISeries. The text in the Rich Text field is fine, but when it gets save to the .txt file it becomes another format. Is this a normal thing ISeries does?

Can anyone tell me what format that is and how do I convert it back to ASCII so I can decode it properly? I’m putting the code it becomes and what it should be below.

Any and all suggestions are greatly appreciated. Thanks for reading.

Tim Williams

Below is a small 2KB file. It should be a .gif image after being decoded. The text below in ASCII is base64 encoded.

ISeries .txt file text:

Ùð“ÇÖÄ“ˆ’‡Â‡ÁȃÁÔâÈNǓեé•Ùóèçѓ։ÂՁæÕ¨‚óե镨‡ãò锁æÕ“ÁÃÈõÂÁÅÁÁÁÁÁÓÁôÁ%ÅÁÂñÁÄðÁˆØÁÁÁÁÁÁÁÂÅÙŇäÅÂÁ¢ÑǃLJƒÇ¦¢ÒLJȦÔÄÁ¦¦Òæ’ÈÃÁèÆÂØ–ÉÃØ’ÉÃÄèñ%ÕÃ’—ÒäôÂÁåõ…ç’ˆÉâåù†è•“ó…”„“Çù¥ƒ–N×’ô˜Ò‘—‰ç•éÇדéò‚–Ò˜—¢Çˆ—÷òò¤÷Na§„äÅ%¢ˆæ£§ó„ø¨ø¥„¨¢ù‘äòÔçÆ¨øóÓðÕa†ô¥’密ƒÆÂ¥–óÖ†ô”Ò†åÔ㥣¨„׈ˆè¤æÑ‰¥öâ’N‰…%•N”§¢aN˜™¥aƒóÖ©‚óÖ¥Ó©…÷–ö…a¥ø…÷òN×aaa¦ÅÃÁ¦ÅÃÁ¦ÅÃÁ¦‚aØÉ¦â恑ø‰’¢ƒÑ¢Ö—øæ%—çÙҙ嘥¨’™È¢Nñð׈N¥éø©Â×ÓÄ–£È—„™É©È󥑂äøöƒò†‘øÖ‰ã§†ô¥‡èÒÂÔÉæÇÔÃÉ…ÇÙ’%ÅȘגÆÔ¨ÔÃöåÓæ£”阁җò„ÅÙòÓÑ–òÙ—éÃÔ—è£Õ‘è¥Òö¦òÓ˜øøÕ‰¢™ÉâÅÙÈöÒ‘„ö…a…Ò”ç%˜¨˜ñ£aÆ£™…ô¤ˆ‡éÑ‘’õÈ–÷Áñæ’¨¦ö¤£¨ÔçÆÖãÇô©Ã؁ÇÙø•ѧø¥£‚¢ä©Çè”い§Ô•Èô‚’•%ȈÓ÷aÂÉÃ÷ØÃå¥ÕÖäØ§Ô¢æ‚ç¤õäѧ–‡ÔÈÄÙÁ§‚Á‡Ø¢ÒÒÙ„õ†‡é†Ò’‚Æ”ôÃÃè臇ĩ¦ØÔljˆéã%ÁˆÁÙ–çÓ“©Â‘—‘ÁÙø£§ÉĨˆåö‰ÙâÉâÙÕaò‘Ù‚™‰‡Åâóȩі•ØÉÄɤçÕ•ˆÙ¦ðé§èåâ‘ãäè‚•%ã‘£˜¥Ò—‰ÙÙÆ‰ô˜–—ä”å˜ñƒ”ó–ÆÇaèlj§ƒõ„Ââù‰‡ÓÆñ™Øå•÷ÒÕ§–×Èȧ‡ô„Ô‰Õ鈁Ɖ‚£ô%ÁãôÕ”ôÕÈĈÅóÔÁØ×ב˜ôƒÙ„ÇØ¤”ÉäÓ¤‰§‰Ô†ñ÷Ç‚ÈÆ§ä‚“‘¨ց؁ÕÇ‘ÙÉNÅé֤鑘‘ˆ‰Ø%ƒƒ©ôÃôÖÆ‰Â‡‘è—¦è×墧èöǤNÃôäåØóƒÖÈʼn÷Ö™¢×ƒ‚çÔÇÔ‘é˜èÁæÖô‚Ö””…’‘ÔØ×¨Ä‡ð†%–’”É„¢ÑÃÄ—Æò¦‚ƒã×öÔǑ™ÙÑ™‡aÔâÈÈÃÙØâðÁãÇä¥ÑÕé¦ÉÕ•ôÆ”“Áç“×ÃÃÂÇÙ—ÔÔÉÅNÅ•ã¦%çèÇ×ùÉã‡ÄÅæñ“aNÂÂ…ñÙøÔÅÅÇçĦ‡ÁäãæÉ‡ˆ‚â‘¦ÔÆ‡ðÇ“ˆ‡‡ØØ‡âŧÕä–ÔôÆçñ¨ôɈôå%£Öˆ‰äÙ”‡øÅÅÆÆÆâÁ¦ØØ÷ÔÖÂÂÆ™ôNÖԁ׆äñõƦaèãåâÇÂðØÖÒä—Å‘¦‡——‡ØØ×ÂÁ”æ‡Ò–ց%ð™õõ飦§‰•••Èãæ……„…ց—õõõøù¤•••ôÁÇÒ¤‰‡ˆÂé˜öÒÇÉј™––”’ÆôÒ‡…‘ö™ˆ˜ÒÔÄÅÉÁˆ%ÁéՁ‰’…’äˆÂ؇ÂÇÙLjÄÁÁ‚ÕõÖ‡ØÃÁÙØØÁÁÑõƒÒ˜Å˜ðÑʼn‰”™—ÈǁØÁÁÒÂÑÂÁÅØ¥ƒæ‡Ã—‘ˆ‚Á%‡ÂÃù™ÄÁÅÉôò’ÔÕ؈¨‡‡Ãåã™–å—ùÁâä…¨§Ø§ã÷Ò¦ÃÙ„ˆ¤Á¢‡’ôôÅÁÃÃãØ¦ˆÒ‘ǧˆ™aÁÁÈ’%”‰¢£ÁчÁÉÖ”‡Ò¦¦ÓƒÈ—Ô™£¤’ÉôøÇðÄÁ㉇ӇÉÁðø˜Á—†•¤Ã¤¤N¨Ö‚’‚¦ÔÁÃò¦¥¥¥—ö˜òôÄ%¤Øƒ÷¦ÂÖÁ—§¦×¢ò’ÓÃöÈçøÓÁÔÄèÁ•™Åé¦Ö‡ÆÒñÄÈÖ÷˜§ÁÅÓÔÄÁ–¦£ã”õ×Ó¢çÒ¢ø™Ø¥Âðñ¨%©Ã£©¨÷ÈÆÔ‚¤¢ØÔøÕ¢õ¦ãð’‡Ä‚ÅÃNÆÖçøùÔ¦§Éùñðñ’Ñ©aâ÷䯯ţ÷ˆÃÆÓðñÁĦ‚ׂ⤁ñ„ù%“ö¨™Ä—Åò©Çó‚ã†ÙØÕ£ù™÷“ÖŦ¢§ƒÕ¨N•ÄÅÁ§„ƒù˜‡Á¤¦ð˜â˜Òâò¤NaÉÅø¢ƒ‡ÄĤ•¨Á¥ñð‘%÷†ÈÇçÑÕ¢NÙÃaõð˜¢Å©ñ”’ÄÒ‘™É÷‚Õa’ó’¢Ù¦Ò¢ó÷Ö‘Â¥Óé¤Åæò¦—Ö‚‚…é„ÁôĘöÑò†ãÈ’Ø%ÁÄ¢~%

This is the original ASCII base64 text contained in the Rich Text field and transferred to the .txt field successfully on Windows servers:

R0lGODlhkgBgAHcAMSH+GlNvZnR3YXJlOiBNaWNyb3NvZnQgT2ZmaWNlACH5BAEAAAAALA4A

EAB1AD0AhQAAAAAAABEREgUEBAsJCgcGBgcGBwsKCggHBwMDAwwKCwkHCAYFBQoICQkICDY1

NCkpKU4BAV5eXkhISV9fYnl3emdlaG9vco+Pk4qKjpiXnZGPlZ2boKqpsaGhp722u7+/xdUE

BshaWtx3d8y8vdays9jU2MXFy83L0N/f4vkVFfcFBvo3Of4mKfVMTvtydPhhYuWJiv6Sk+ie

n+mxs/+qrv/c3Ozb3OvLze7o6e/v8e72+P///wECAwECAwECAwb/QIBwSCwaj8ikscJsOp8W

pXRKrVqvykrHs+10Ph+vZ8zBPLDotHpdrIzH3vjbU86c2fj8OiaTxf4vgYKBMIWGMCIeGRka

EHqPkFMyMC6VLCwtmZqaKp2dER2LJo2RpaZCMpYtNjYvK6w2Lq88NisrISERH6Kjd6e/eKmX

qyq1ta/Ftre4uhgZJjk5Ho7A1Wkyw6utyMXFOTG4zCQaGR8nJx8avtbsUzGYmTadxMnH4bkn

HhL7/BIC7QCVvNOUQxMsWbXu5UJxogMHDRAxbAgQsKKRd5fgZfKkbFm4CCYYggDzwQMGihZT

AhARoaXLlzBjpjAR8txIDyhV6iRSISRN/2jRbrigES3HzJonQIDIuXNnhRw0ZxYVSjTaUYbn

TjBtqvKpiRRFi4qoapUmVq1cm3oFG/YGixc5dBS9igLF1rQVn7KNxoPHHxg4dMiNZhaFibt4

AT4Nm4NHDhE3aMAQPPjq4cRdGQumIULuixiMf17GbHFxUbljByOaQaNGjRI+EZOuZjqajhiQ

ccz4C4OFiBgjYpwYPVsxY6Gua+C4UVQ3cOHEi7OrsPcbXMGMjZqYAWO4bOmmekajMQPyDg0f

okmIdsJCDpF2wbcTP6MGjBrRJrg/MSHHCRQS0ATGUvJNZwINn4FmlAXlPCCBGRpMMIE+EnTw

XYGP9ITgDEW1l/+BBe1R8MEEGXDwgAUTWIghbSjwMFg0GlhggQQgSEBBBxNUoM4FX1y4Ih4V

tOhiURmg8EEFFFSAwQQa7MOBBFr4+OMaPfU15Fw/YTVSGB0QOKUpEjwgppgQQPBAmWgKoOaa

a0r55ZtwxinnnHTWaeedeOap55589unnn4AGKuighBZq6KGIJqroomkF4Kgej6rhqKMDEIAh

AZNaikekUhBQgBGRGhDAAbN5OgQCARQQAAJ5cKqEq0JEiimrpHGaQAAKBJBAEQvcWgCpjhbA

gBC9BrDAEI42kMCnQhygagCVTroVp9ASUeyxQxT7KwCRdhuAsgk44EACCTQwhKjGxhr/AAHk

mistAJgaAIComgKwwLcHpMrtukI48G0DATigLgIA08qApfnuCuu+yObkbwMAC2wvvvp6q24D

uQac7wBCoApxwPs2kLC6HX8LAMDYAnBrEZwOgFK1DHO7qxAELMDAowtTm5PLsXKs8rQvB01y

zCtzy7HFMbusQM8Ns5wT0kgDbEC+FOX89MwxI9101kJz/S7UFFEt7ahCFL01ADwbPbSua1d9

l6yrDpE2zGa3bTfRQNt9r7lCoEwsxcNy+nDEAxdc9qgAuw0qSqKS2u+/IE8scgDDunyAv10j

7fHGXJNs+RCc/50qsEz1mkDKjrI7bN/k3ksRwKs37OjBvLZuEW2wpCobbeZdA4Dq6J2fTHkQ

ADs=

Subject: Saving text file to ISeries IFS being converted from ASCII to ??

I am not certain that this is current information or not, but the AS/400 used Extended Binary Coded Decimal Interchange Code (EBCDIC) for its ‘text’ storage.

I think that there was a way to force the 400 to store in ASCII, but that is long ago and far away memory.

To learn more see EBCDIC - Wikipedia

Subject: Saving text file to ISeries IFS being converted from ASCII to ??

It’s being saved as EBCDIC. Here’s how you can convert it to ASCII:

lReturn = Shell(“COPY OBJ('” & yourextractedfilename & “‘) TOOBJ(’” & thenewfilename & “') TOCCSID(*PCASCII) DTAFMT(*BINARY) REPLACE(*YES)”)

'Delete the EBCDIC file now that you have it in ASCII.

lReturn = Shell(“DEL OBJLNK('” & yourextractedfilename & “')”)

HTH,

Charles

Subject: RE: Saving text file to ISeries IFS being converted from ASCII to ??

Charles,

I tried this code you suggested but it doesn’t convert the text. Is there particular settings one must set in order for the server to convert it using this shell command?

Can you think of why it didn’t convert the text?

I did try out an online tool to convert EBCDIC text to ASCII and it works, so I know the text is indeed EBCDIC. Any thoughts on why it doesn’t convert it? I get two files, but both are identical.

Thanks for your help.

Tim Williams

Subject: Saving text file to ISeries IFS being converted from ASCII to ??

I am not certain that this is current information or not, but the AS/400 used Extended Binary Coded Decimal Interchange Code (EBCDIC) for its ‘text’ storage.

I think that there was a way to force the 400 to store in ASCII, but that is long ago and far away memory.

To learn more see EBCDIC - Wikipedia

Subject: Saving text file to ISeries IFS being converted from ASCII to ??

Charles Robinson’s method of using Shell commands to convert the file to ASCII should work. If interested in why it didn’t work, you would need to look in the job log of the Domino program (server, amgr, http) that is running the agent. There should be an error message(s) logged.

However, starting in 6.0, using the Shell commands to convert the file to ASCII on the iSeries is no longer necessary, because LotusScript was enhanced so the character set of the file could be specified on the open. Take a look at the Open LotusScript statement. You will want to specify the character set of the file on the Open statement via the Charset element.

Subject: RE: Saving text file to ISeries IFS being converted from ASCII to ??

Oh, I didn’t know that had been changed. I put this code in place about 7 years ago on R5 and it’s been working ever since. :slight_smile:

Subject: Saving text file to ISeries IFS being converted from ASCII to ??

Try to specify ASCII as character set n OPEN statement:Open “ASCII.TXT” for output Access write _

as ff CHARSET=“ascii”

Another solution is to copy a file created in Windows to AS400 and use that file for operations. Once created in Windows format, the file keeps it’s characterset property.