473,804 Members | 3,570 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Read Unicode data from Text file

I am using the FileSystemOBjec t 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("S cripting.FileSy stemObject")
Set var_txt_file = var_file_sys.Cr eateTextFile(vn _export_file, True,
True)

var_txt_file.wr iteline (var_line)

var_txt_file.Cl ose

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

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

Set var_file_sys = CreateObject("S cripting.FileSy stemObject")
Set var_f = var_file_sys.Ge tFile(vnp_impor t_file)
Set var_txt_file = var_f.OpenAsTex tStream(ForRead ing,
TristateTrue)

var_text = var_txt_file.Re adLine

var_txt_file.Cl ose

Nov 9 '07 #1
4 15619
"Chris" <CL*****@gmail. comwrote in message
news:11******** **************@ 57g2000hsv.goog legroups.com...
>I am using the FileSystemOBjec t 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("S cripting.FileSy stemObject")
Set var_txt_file = var_file_sys.Cr eateTextFile(vn _export_file, True,
True)

var_txt_file.wr iteline (var_line)

var_txt_file.Cl ose

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

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

Set var_file_sys = CreateObject("S cripting.FileSy stemObject")
Set var_f = var_file_sys.Ge tFile(vnp_impor t_file)
Set var_txt_file = var_f.OpenAsTex tStream(ForRead ing,
TristateTrue)

var_text = var_txt_file.Re adLine

var_txt_file.Cl ose
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("S cripting.FileSy stemObject")
Set a = fso.CreateTextF ile("c:\temp\te stfile.txt", -1, -1)
a.WriteLine("Th is is a test.")
a.Close
End Sub

Sub ReadFile
Set fso = CreateObject("S cripting.FileSy stemObject")
Set f = fso.OpenTextFil e("c:\temp\test file.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.goog legroups.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 OpenAsTextStrea m 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
5539
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 difficult to get PHP to understand. I have two files, a text file containing data to display and a php file with a script to display the data. I can get the contents of a text file displayed in English, no problemo, but in Japanese, it's another...
8
4072
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 problems getting my algorithm to work and in order to help me find the solution I decided to print each line to screen as I read them. Then, to my surprise, I noticed that there was a space between every character as I outputted the lines to the...
2
4044
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 do it Thanks Abel
1
3149
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 that exporting the Chinese text (unicode data) is not as straight forward as we had hoped. We can enter the Chinese on the forms and it is stored in the tables, but is converted to ??? when exported using Print functions. There is a lot of...
1
3236
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 implement... saran
1
2203
by: christine0207 | last post by:
Hi, how to generate a fixed length data text file using Scripting.TextStream / filesystemobject.
2
7363
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 1111 4 A
1
1682
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
2227
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, line;
0
9705
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9576
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10567
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10323
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9138
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7613
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5515
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3809
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.