I want to convert an ebcdic string to a utf8 string. I use the below online tool to test this, which is very good, for conversion related stuffs.
http://kanjidict.stc.cx/recode.php
I want to convert £ˆ‰¢‰¢¤£†ø which is in EBCDIC to UTF8 string, which is thisisutf8 You can use the above link to test.
I refered the below article on how to read EBCDIC data in .net
http://www.codeproject.com/KB/vb/EasyEbcdicToAscii.aspx
Then I used the same method to read the ebcdic data
Dim encoding As System.Text.Encoding = _
System.Text.Encoding.GetEncoding(37)
However I am not getting the expected data
Here is my code, to get the result into a atring, a.
Dim a As String = System.Text.Encoding.UTF8.GetString(System.Text.Encoding.GetEncoding(37).GetBytes("£ˆ‰¢‰¢¤£†ø"))
That’s too late, looks like you already converted it to a string. You’ll need to read bytes instead. Then use Encoding.GetString() to convert the ebcdic encoded bytes to a .NET string. Then use Encoding.UTF8.GetBytes() to convert that back to bytes.
Alternatively, and more practically, use the StreamReader(string, Encoding) overload to open the ebcdic file, passing the ebcdic Encoding. And StreamWriter(string) to write it back, it already defaults to utf-8.