Connecting Tech Pros Worldwide Help | Site Map

Read Unicode data from Text file

  #1  
Old November 9th, 2007, 09:15 AM
Chris
Guest
 
Posts: n/a
I am using the FileSystemOBject for writing text with Unicode as in
the example below. When I try to read data from the file with
ReadLine, I get "?????????" instead of characters with unicode.

What could be the problem ?

Thanks a lot in advance!

------------------------------------------------------------------------------------------------

Dim var_file_sys As Object
Dim var_txt_file
Dim var_line As String

Set var_file_sys = CreateObject("Scripting.FileSystemObject")
Set var_txt_file = var_file_sys.CreateTextFile(vn_export_file, True,
True)

var_txt_file.writeline (var_line)

var_txt_file.Close

------------------------------------------------------------------------------------------------

Const ForReading = 1, TristateTrue = -1
Dim var_f As Object
Dim var_text As string

Set var_file_sys = CreateObject("Scripting.FileSystemObject")
Set var_f = var_file_sys.GetFile(vnp_import_file)
Set var_txt_file = var_f.OpenAsTextStream(ForReading,
TristateTrue)

var_text = var_txt_file.ReadLine

var_txt_file.Close

  #2  
Old November 9th, 2007, 10:05 AM
Stuart McCall
Guest
 
Posts: n/a

re: Read Unicode data from Text file


"Chris" <CLarkou@gmail.comwrote in message
news:1194599649.145304.222170@57g2000hsv.googlegro ups.com...
Quote:
>I am using the FileSystemOBject for writing text with Unicode as in
the example below. When I try to read data from the file with
ReadLine, I get "?????????" instead of characters with unicode.
>
What could be the problem ?
>
Thanks a lot in advance!
>
------------------------------------------------------------------------------------------------
>
Dim var_file_sys As Object
Dim var_txt_file
Dim var_line As String
>
Set var_file_sys = CreateObject("Scripting.FileSystemObject")
Set var_txt_file = var_file_sys.CreateTextFile(vn_export_file, True,
True)
>
var_txt_file.writeline (var_line)
>
var_txt_file.Close
>
------------------------------------------------------------------------------------------------
>
Const ForReading = 1, TristateTrue = -1
Dim var_f As Object
Dim var_text As string
>
Set var_file_sys = CreateObject("Scripting.FileSystemObject")
Set var_f = var_file_sys.GetFile(vnp_import_file)
Set var_txt_file = var_f.OpenAsTextStream(ForReading,
TristateTrue)
>
var_text = var_txt_file.ReadLine
>
var_txt_file.Close
Not sure why it isn't working for you, but FWIW I msdr this test.vbs file,
and itworks perfectly. Maybe it'll give you a clue.

''' START CODE '''
Writefile
ReadFile

Sub Writefile
Set fso = CreateObject("Scripting.FileSystemObject")
Set a = fso.CreateTextFile("c:\temp\testfile.txt", -1, -1)
a.WriteLine("This is a test.")
a.Close
End Sub

Sub ReadFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("c:\temp\testfile.txt", 1, 0, -1)
MsgBox f.ReadLine
f.Close
End Sub
''' END CODE '''


  #3  
Old November 9th, 2007, 10:45 AM
Chris
Guest
 
Posts: n/a

re: Read Unicode data from Text file


Thanks a lot Stuart for your message.

I could read the data from text file, the problem was appearing when I
had unicode characters (languages other than English). I was not able
to view the data read in VB, because ????????? were appearing, but
when I saved them in Access file, it seems to be ok.

  #4  
Old November 9th, 2007, 12:05 PM
Stuart McCall
Guest
 
Posts: n/a

re: Read Unicode data from Text file


"Chris" <CLarkou@gmail.comwrote in message
news:1194604652.684890.175430@o3g2000hsb.googlegro ups.com...
Quote:
Thanks a lot Stuart for your message.
>
I could read the data from text file, the problem was appearing when I
had unicode characters (languages other than English). I was not able
to view the data read in VB, because ????????? were appearing, but
when I saved them in Access file, it seems to be ok.
I must admit to hardly any knowledge of languages other than English, but
this problem of yours I find intriguing. Could you instruct me how to enter
some non-English characters so I may run a test or two? Do I simply switch
fonts?



  #5  
Old November 12th, 2007, 11:05 AM
Chris
Guest
 
Posts: n/a

re: Read Unicode data from Text file


Unfortunately I got the database from the country that entered the non-
english characters, I did not type them my self.

It seems to be working now, I use the OpenAsTextStream for reading
Unicode characters from TXT files and I insert them in an Access
database. Then I read the non-english characters from the Access
database for further processing.

Thanks a lot!!

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to read a Unicode data saved as ASCII in notepad file as txt ? Learning.Net answers 3 August 8th, 2007 03:55 PM
Reading UTF data from c# Sivaraj G via .NET 247 answers 3 November 16th, 2005 11:30 AM
UTF8/UTF7/ASCII problem while reading from text file Lenard Gunda answers 5 November 16th, 2005 09:28 AM
Extract unicode data from MySQL db JJ answers 2 July 17th, 2005 04:16 AM