Friday, January 30, 2015

CCSIDs a.k.a Code Pages in IBM PASE for i

It all started with iconv() function in iSeries PASE. I need to figure out how to convert strings back and forth between iSeries PASE and ILE programs. I didn't realize at first that there were TWO instead of one libiconv library installed on the iSeries I worked with. One from GNU and one from IBM (the original one). I had to specify the one I intend to use specifically in my as follows:

 pase_to_rpg_string_LDADD = /QOpenSys/QIBM/ProdData/OS400/PASE/lib/libiconv.a

Well, then it turned out, the code page "string" specified for ILE C didn't work out. I found out that the code page string should be as shown here. I'm puzzled as to where that guy found the code page string. Then, I finally found that it was AIX code page specification after all, as this link shows. I reproduce it below, just in case (and hopefully IBM doesn't mind ;).

Table 1. CICS Shortcodes, CCSIDs and code pages that TXSeries for Multiplatforms supports
CICS short code nameCCSIDAIX® and Windows code pageHP–UX code page nameSolaris code page nameDescription
3737IBM-037american_eIBM-037IBMLatin-1 EBCDIC
8859-1819ISO8859-1iso8859_18859Latin-1 ASCII (ISO)
819819ISO8859-1iso8859_18859Latin-1 ASCII (IBM/ISO)
850850IBM-850roman8IBM-850Latin-1 ASCII
437437IBM-437iso8859_1IBM-437Latin-1 (PC) ASCII
930930IBM-930cp930IBM-930Japanese EBCDIC
931931IBM-931japanese_eIBM-931Japanese EBCDIC
939939IBM-939cp939IBM-939Japanese EBCDIC
932932IBM-932sjisja_JP.pckJapanese ASCII
EUCJP954IBM-eucJPeucJPeucJPJapanese ASCII (ISO)
942942IBM-942IBM-942IBM-942Japanese ASCII
943943IBM-943IBM-943IBM-943Japanese ASCII
934934IBM-934IMB-934IBM-934Korean ASCII
944944IBM-944IBM-944IBM-944Korean ASCII
949949IBM-949korean15IBM-949Korean ASCII
933933IBM-933korean_eIBM-933Korean EBCDIC
EUCTW964IBM-eucTWIBM-eucTWeucTWTraditional Chinese
938938IBM-938IBM-938IBM-938Traditional Chinese ASCII
948948IBM-948IBM-948IBM-948Traditional Chinese ASCII
937937IBM-937chinese-t_eIBM-937Traditional Chinese EBCDIC
BIG5950Zh_TW.big5big5zh_TW.BIG5Traditional Chinese BIG5
946946IBM-946IBM-946IBM-946Simplified Chinese ASCII
13811381IBM-1381hp15CNIBM-1381Simplified Chinese ASCII
935935IBM-935chinese-s_eIBM-935Simplified Chinese EBCDIC
EUCN1383IBM-eucCNchinese-s_eeucCNSimplified Chinese ASCII (ISO)
GB180305488GB18030gb18030GB18030Simplified Chinese GB18030
864864IBM-864arabic8IBM-864Arabic ASCII
8859-61089ISO8859-6iso8859_6ISO8859-6Arabic ASCII (ISO)
10891089ISO8859-6iso8859_6ISO8859-6Arabic ASCII (IBM/ISO)
420420IBM-420arabic_eIBM-420Arabic EBCDIC
855855IBM-855IBM-855IBM-855Cyrillic ASCII
866866IBM-866IBM-866IBM-866Cyrillic ASCII
8859-5915ISO8859-5iso8859_5ISO8859-5Cyrillic ASCII (ISO)
915915ISO8859-5iso8859_5ISO8859-5Cyrillic ASCII (IBM/ISO)
10251025IBM-1025IBM-1025IBM-1025Multilingual Cyrillic EBCDIC
869869IBM-869greek8IBM-869Greek ASCII
8859-7813ISO8859-7iso8859_7ISO8859-7Greek ASCII (ISO)
813813ISO8859-7iso8859_7ISO8859-7Greek ASCII (IBM/ISO)
875875IBM-875greek_eIBM-875Greek EBCDIC
856856IBM-856hebrew8IBM-856Hebrew ASCII
8859-8916ISO8859-8iso8859_8ISO8859-8Hebrew ASCII (ISO)
916916ISO8859-8iso8859_8ISO8859-8Hebrew ASCII (IBM/ISO)
424424IBM-424hebrew_eIBM-424Hebrew EBCDIC
273273IBM-273german_eIBM-273Austria, Germany EBCDIC
277277IBM-277danish_eIBM-277Denmark, Norway EBCDIC
278278IBM-278finnish_eIBM-278Finland, Sweden EBCDIC
280280IBM-280italian_eIBM-280Italy EBCDIC
284284IBM-284spanish_eIBM-284Spain, Latin Am.(Sp) EBCDIC
285285IBM-285english_eIBM-285UK EBCDIC
297297IBM-297french_eIBM-297France EBCDIC
500500IBM-500IBM-500IBM-500International latin-1 EBCDIC
871871IBM-871icelandic_eIBM-871Iceland EBCDIC
852852IBM-852IBM-852IBM-852Latin-2 ASCII
8859-2912ISO8859-2iso8859_2ISO8859-2Latin-2 ASCII (ISO)
912912ISO8859-2iso8859_2ISO8859-2Latin-2 ASCII (IBM/ISO)
870870IBM-870IBM-870IBM-870Latin-2 EBCDIC
857857IBM-857turkish8IBM-857Turkey ASCII
8859-9920ISO8859-9iso8859_9ISO8859-9Turkey ASCII (ISO)
920920ISO8859-9iso8859_9ISO8859-9Turkey ASCII (IBM/ISO)
10261026IBM-1026turkish_eIBM-1026Turkey EBCDIC
UTF-81208UTF-8 (only)UTF-8UTF-8Unicode file code set
UCS-21200UCS-2 (only)UCS-2UCS-2Unicode processing code set

So, next time, you code on iSeries PASE, use "IBM-037" (EBCDIC code page) and "ISO8859-1" (ASCII 8-bit) strings to convert back and forth.

I hope this post will somehow save somebody someday.

Saturday, December 27, 2014

Telegram (CLI) on Raspberry Pi

This post (in German) explains how to build Telegram Command Line Interface (CLI) client. I confirmed that those steps also works in my Raspberry Pi type B board, minus the Lua component. I had to disable Lua because I cannot get it to compile in my Raspberry Pi (running Raspbian). The compilation always failed because it doesn't have enough space in /tmp for the intermediate compilation result. Well, I don't have any need for Lua either.

Now, let's get down to the details. These are the steps (I'll repeat the steps in the linked article above for completeness sake):
  1. In order to make sure you have enough /tmp for the compilation, you can enlarge your /tmp as explained in this post (basically edit /etc/fstab and unmount, remount /tmp or reboot your Raspberry Pi to be sure).
  2. Install the needed libraries in your Raspbian:
    sudo apt-get install libreadline-dev libconfig-dev libssl-dev libevent-dev
    I leave all Lua-related stuff out because we don't need it.
  3. Next, let's clone Telegram CLI from github:
    [your_home_dir]: git clone --recursive && cd tg
  4. Now, let's make a build directory in order not to clutter the source code with intermediate object files there.
    [your_home_dir]/tg: mkdir build && cd build
  5. Now carry out the compilation there. Remember to disable lua:
    [your_home_dir]/tg/build: ../configure --disable-liblua
    [your_home_dir]/tg/build: make
    Grab yourself some coffee to wait for the compilation to complete.
Once the compilation complete, you'll have Telegram CLI executable (named telegram-cli) in the tg/build/bin directory. Now, you can start using it. Just a hint: to end your telegram-cli session, type:
In the current telegram-cli session. You can just type "/" then "TAB" to see the options available to you. It also confuse me how to quit when I first uses Telegram CLI ;-)

Thursday, May 29, 2014

Batch Encoding mp4 Videos to Wav (Audio CD format) in Windows

At times, you want to listen to your favorite tunes while driving in congested roads or for extended period of time between cities. The problem is, your car's audio only support Audio CD. This dictates you to convert your favorite tunes to Audio CD. Moreover, you don't have enough time to convert them one by one. Enter the "batch encoding" realm..
Simply put, batch encoding is the process of encoding multiple files in one go. To do that, we use shell script, or batch file in Windows. Because most of my favorite tunes are mp4 videos, my batch encoding script converts those mp4s into wav files. I used VLC to carry out the encoding and I'm using a powershell script to automate the encoding into batch encoding. This is the powershell script that I use:
$outputExtension = ".wav"
$bitrate = 128
$channels = 2

foreach($inputFile in get-childitem -Filter *.mp4)
  $outputFileName = [System.IO.Path]::GetFileNameWithoutExtension($inputFile.FullName) + $outputExtension;
  $outputFileName = [System.IO.Path]::Combine($inputFile.DirectoryName, $outputFileName);
  echo "Output filename: $outputFileName" 
  $programFiles = ${env:ProgramFiles(x86)};
  echo "Program Files: $programFiles"
  if($programFiles -eq $null) { $programFiles = $env:ProgramFiles; }
  $processName = $programFiles + "\VideoLAN\VLC\vlc.exe"
  echo "processName: $processName"
  $processArgs = "-I dummy -vvv `"$($inputFile.FullName)`" --sout=#transcode{acodec=`"s16l`",ab=`"$bitrate`",`"channels=$channels`"}:standard{access=`"file`",mux=`"wav`",dst=`"$outputFileName`"} vlc://quit"

  echo "processArgs: $processArgs"
  start-process $processName $processArgs -wait

It's not that complicated. It's a slightly modified script from VLC wiki ( There was one hiccup though because by default poweshell doesn't permit script execution. Therefore, I have to run powershell as administrator and then modify the execution policy to unrestricted like so:
Windows PowerShell
Copyright (C) 2013 Microsoft Corporation. All rights reserved.

PS C:\Users\zzz> Set-ExecutionPolicy Unrestricted
Anyway, the powershell script above assumes that you placed all of the mp4 in the current directory (directory where the powershell script located). The batch encoding result will be located in the current directory as well.
Now, to create audio CD, you'll need the application to burn the wav files into audio CD. I'm using cdrecord in Linux to do this because for some reason, the only machine with CD/DVD writer that I have is running Linux. You can use your favorite CD authoring application to do this.

Happy Encoding!

Tuesday, May 20, 2014

AS400 Programming Tutorial

After searching the web for sometime on AS400 RPG-ILE tutorial, I found the most newbie friendly tutorial over at: RPG-ILE is also known as RPG IV or RPG400. I'm not yet quite familiar with the AS400 hardware but it seems it's a Power machine. The OS400 on the other hand is a specific OS developed by IBM for the AS400 hardware.

IBM provides a more comprehensive tutorial in the ILE RPG Programmer's Guide. However, to save time, I prefer to read an overview on the language itself and the tutorial in the link above is just what I need to bootstrap learning the ILE RPG. I hope this post is of some use for those starting with ILE RPG on IBM Series i machines, like me. Happy coding :)