문제

I have an application which converts ASCII encoded file to EBCDIC encoded file. My problem is that, whenever I try to use other conversion tool(EBCDIC to ASCII), I am having a problem.


This is where I got my codes http://support.microsoft.com/kb/216399


CS?NTPRC?37-MAY MTLAW 4RY? - This should be the result looks like.

CcCs@@CnCtCp$$CrCc@@C?C?-CmCaCy CmCtClCaCw C?$$CrCy@@CmCtClCaCw$$ - This content of my file.

도움이 되었습니까?

해결책

Don't use that code, dealing with different encodings is very well supported in .NET:

Imports System.IO
Imports System.Text

Module Conversions
    Public Sub ConvertAsciiToEbcdic(ByVal inpath As String, ByVal outpath As String)
        Using sr As New StreamReader(inpath, Encoding.ASCII)
            Using sw As New StreamWriter(outpath, False, Encoding.GetEncoding(37))
                Do
                    Dim line = sr.ReadLine()
                    If line Is Nothing Then Exit Do
                    sw.WriteLine(line)
                Loop
            End Using
        End Using
    End Sub
End Module

Just swap the Encodings if you want to convert the opposite way.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top