473,396 Members | 2,154 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

Nov 9 '07 #1
4 15522
"Chris" <CL*****@gmail.comwrote in message
news:11**********************@57g2000hsv.googlegro ups.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 '''
Nov 9 '07 #2
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.

Nov 9 '07 #3
"Chris" <CL*****@gmail.comwrote in message
news:11**********************@o3g2000hsb.googlegro ups.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?

Nov 9 '07 #4
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!!

Nov 12 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: David Thomas | last post by:
Hi there, I am trying to store data in a text file and output it to the browser using PHP. All very easy - if I was using English! the problem is, I want to use Japanese and I'm finding it a tad...
8
by: Eric Lilja | last post by:
Hello, I had what I thought was normal text-file and I needed to locate a string matching a certain pattern in that file and, if found, replace that string. I thought this would be simple but I had...
2
by: Abel | last post by:
Hi to all I'm trying to read an old MS-DOS text file, using a StreamReader, but I can't retrieve the original text, I have used all the possible encoding UTF-7,UTF-8, Unicode and ASCII. How I can...
1
by: watto | last post by:
We have a rather large application built around Access 2k3 which will soon be used for a project in China. The data is exported into CSV files for use by another application. We are just learning...
1
by: Saravanan | last post by:
I need to read in a text file as strings and then write some of these strings into another text file. The output file is in the working directory while the input text file is not. how can I...
1
by: christine0207 | last post by:
Hi, how to generate a fixed length data text file using Scripting.TextStream / filesystemobject.
2
by: apedosmil8 | last post by:
Hello, I am trying to read from a text file and this is what I have so far. The text file looks like this but longer. 0 111111112 15 155 1 1111 4 A 1 1112 4 B 1 1113 3 C 0 111111111 30 90...
1
by: MiziaQ | last post by:
How can I delete a row of data from a data/text file in vb6 ? I am using an MSFlexGrid, so the user can select which row is to be deleted. Thanks in advance, MiziaQ
2
by: kino | last post by:
Hello, I am supposed to read from a text file a series of numbers and then store them in a struct array. Here's my code: int main() { ifstream In; string folder, filename, name2,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.