Connecting Tech Pros Worldwide Help | Site Map

Read Unicode data from Text file

 
LinkBack Thread Tools Search this Thread
  #1  
Old November 9th, 2007, 08:15 AM
Chris
Guest
 
Posts: n/a
Default Read Unicode data from Text file

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, 09:05 AM
Stuart McCall
Guest
 
Posts: n/a
Default 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, 09:45 AM
Chris
Guest
 
Posts: n/a
Default 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, 11:05 AM
Stuart McCall
Guest
 
Posts: n/a
Default 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, 10:05 AM
Chris
Guest
 
Posts: n/a
Default 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!!

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,840 network members.