Hi All,

I need a help converting CP437 (http://en.wikipedia.org/wiki/.nfo) to UTF-8. Its like this online converter.. http://kanjidict.stc.cx/recode.php

EG: I need this ▄ converted to

▄

& #9604; with a space because this software converts it already

Look for samples on the internet but cant find any.. Im total noob so be easy on me :D

Thank you in advance!

When reading the file, first create a StreamReader object.
You can use arguments in it's constructor.
Try this...

Dim file As New StreamReader("filename", Encoding.GetEncoder(437))
Dim content As String
content = file.ReadToEnd
file.Close()

Alright.
You want to convert the text into HTML entities.

This function should do it:

Private Sub SomeMethod()
   Dim file As New StreamReader("filename", Encoding.GetEncoder(437))
   Dim content As String
   content = TextToHtmlEntity(file.ReadToEnd)
   file.Close()

   'content now contains a string of HTML entities
End Sub

Private Function TextToHtmlEntity(ByVal text As String) As String
   Dim textVal As Integer
   Dim encoded As String = ""
   Dim c As Char

   For Each c In text
      textVal = AscW(c)
      If textVal >= 49 And textVal <= 122 Then
         encoded += c
      Else
         encoded += String.Concat("&#",
textVal.ToString(System.Globalization.NumberFormatInfo.InvariantInfo), ";")
      End If
   Next

   Return encoded
End Function
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.