954,514 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

[HELP]convert/encode CP437 to UTF-8 text in richtextbox

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!

Atmos1234
Newbie Poster
3 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
 

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()
Oxiegen
Master Poster
715 posts since Jun 2006
Reputation Points: 87
Solved Threads: 141
 

thank you.. it doesnt work.. Let me post some pictures of what i want.. maby then you understand what i want..

http://imageshack.us/photo/my-images/543/17164776.png/

PLease look at the picture!

Atmos1234
Newbie Poster
3 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
 

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
Oxiegen
Master Poster
715 posts since Jun 2006
Reputation Points: 87
Solved Threads: 141
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You