Read Unicode data from Text file
Read Unicode data from Text file
am 09.11.2007 10:14:09 von Chris
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
Re: Read Unicode data from Text file
am 09.11.2007 10:54:49 von Stuart McCall
"Chris" wrote in message
news:1194599649.145304.222170@57g2000hsv.googlegroups.com...
>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 '''
Re: Read Unicode data from Text file
am 09.11.2007 11:37:32 von Chris
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.
Re: Read Unicode data from Text file
am 09.11.2007 13:03:43 von Stuart McCall
"Chris" wrote in message
news:1194604652.684890.175430@o3g2000hsb.googlegroups.com...
> 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?
Re: Read Unicode data from Text file
am 12.11.2007 11:57:52 von Chris
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!!