Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading Unicode data from a file into stream

Status
Not open for further replies.

passs

Programmer
Dec 29, 2003
170
RU
Hello everybody!

Does anyone know how to solve such problem: I have a file with some german/russian characters and I need to read this data into a stream without any loss.
Currently the code is following:
If LogFileOpenDialog.ShowDialog() = DialogResult.OK Then
CmmlStream = LogFileOpenDialog.OpenFile()
End If
CmmlReader = New StreamReader(CmmlStream, Encoding.ASCII)
CmmlReader.BaseStream.Seek(0, SeekOrigin.Begin)
intTotalLength = System.Convert.ToInt32(CmmlReader.BaseStream.Length())
intLineLength = 0
Try
While CmmlReader.Peek() > -1
strImportLine = CmmlReader.ReadLine()
Catch ex As Exception
MessageBox.Show("Wrong import file format. Operation was canceled. " + ex.Message, Me.Text)
Return
Finally
CmmlStream.Close()
CmmlReader.Close()
End Try

but when I change Encoding.ASCII to Encoding.Unicode I get such rectangles for all the characters. If I use ASCII then I get ???? instead of some unicode characters.

Will be very thankful for any help.
Thanks,
Alex
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top