Hello,
I have a txt file which has a few lines of special characters:
This is A line from the text file:
٦-ŧُ ʍ ѥ ޘ²ů 'ۣ б*'с ',, ꎏЏ
When I use
sr.ReadLine (where "sr As StreamReader"), it is not giving me this line
at all, it gets cut and the characters are totally different.
But when I try a real text file with normal characters, it reads
everything correctly.
How can I read a file, one line at a time and be able to give me the
correct data in VB.NET?
Thanks in advance. You help would be greatly appreciated. 7 2152
<sw**********@y ahoo.com> wrote in message
news:11******** **************@ y41g2000cwy.goo glegroups.com.. . Hello,
I have a txt file which has a few lines of special characters:
This is A line from the text file:
٦?-ŧُ? ʍ?S o?ѥZ? ?~²ů 'ۣT^ б*'с^ ZS',,T ?ZЏ
When I use sr.ReadLine (where "sr As StreamReader"), it is not giving me this line at all, it gets cut and the characters are totally different.
But when I try a real text file with normal characters, it reads everything correctly.
How can I read a file, one line at a time and be able to give me the correct data in VB.NET?
Thanks in advance. You help would be greatly appreciated.
What you are reading is a binary file, not a text file. The binary data may
contain the ascii values of 13, 10, or 0. All of which (i believe) will
keep the StreamReader from reading the full line...
What you should do is read a byte at a time, up to the first ASCII 13. Then
see what data the byte-array contains.
HTH,
Mythran
Have you tried instantiating the StreamReader class instance using the
constructor that accepts an encoding parameter? http://msdn2.microsoft.com/en-us/library/ms143456.aspx
--
Carsten Thomsen
Communities - http://community.integratedsolutions.dk
---------
Voodoo Programming: Things programmers do that they know shouldn't work but
they try anyway, and which sometimes actually work, such as recompiling
everything. (Karl Lehenbauer)
---------
<sw**********@y ahoo.com> wrote in message
news:11******** **************@ y41g2000cwy.goo glegroups.com.. . Hello,
I have a txt file which has a few lines of special characters:
This is A line from the text file:
٦?-ŧُ? ʍ?S o?ѥZ? ?~²ů 'ۣT^ б*'с^ ZS',,T ?ZЏ
When I use sr.ReadLine (where "sr As StreamReader"), it is not giving me this line at all, it gets cut and the characters are totally different.
But when I try a real text file with normal characters, it reads everything correctly.
How can I read a file, one line at a time and be able to give me the correct data in VB.NET?
Thanks in advance. You help would be greatly appreciated.
Is there a quick way to read a file with any format?
Thanks again
Mythran wrote: <sw**********@y ahoo.com> wrote in message news:11******** **************@ y41g2000cwy.goo glegroups.com.. . Hello,
I have a txt file which has a few lines of special characters:
This is A line from the text file:
٦?-ŧُ? ʍ?S o?ѥZ? ?~²ů 'ۣT^ б*'с^ ZS',,T ?ZЏ
When I use sr.ReadLine (where "sr As StreamReader"), it is not giving me this line at all, it gets cut and the characters are totally different.
But when I try a real text file with normal characters, it reads everything correctly.
How can I read a file, one line at a time and be able to give me the correct data in VB.NET?
Thanks in advance. You help would be greatly appreciated.
What you are reading is a binary file, not a text file. The binary data may contain the ascii values of 13, 10, or 0. All of which (i believe) will keep the StreamReader from reading the full line...
What you should do is read a byte at a time, up to the first ASCII 13. Then see what data the byte-array contains. HTH, Mythran
Thank you for your feedback. However, when I tried
sr As StreamReader = New StreamReader(sF ileName,
System.Text.Enc oding.ASCII)
It give me "????....."
Basically they are ASCII between 128 and 255. What should I be using,
or how should I declare it in order to get those characters back?
Thanks in advance.
Wanda
CT wrote: Have you tried instantiating the StreamReader class instance using the constructor that accepts an encoding parameter? http://msdn2.microsoft.com/en-us/library/ms143456.aspx
-- Carsten Thomsen Communities - http://community.integratedsolutions.dk --------- Voodoo Programming: Things programmers do that they know shouldn't work but they try anyway, and which sometimes actually work, such as recompiling everything. (Karl Lehenbauer) --------- <sw**********@y ahoo.com> wrote in message news:11******** **************@ y41g2000cwy.goo glegroups.com.. . Hello,
I have a txt file which has a few lines of special characters:
This is A line from the text file:
٦?-ŧُ? ʍ?S o?ѥZ? ?~²ů 'ۣT^ б*'с^ ZS',,T ?ZЏ
When I use sr.ReadLine (where "sr As StreamReader"), it is not giving me this line at all, it gets cut and the characters are totally different.
But when I try a real text file with normal characters, it reads everything correctly.
How can I read a file, one line at a time and be able to give me the correct data in VB.NET?
Thanks in advance. You help would be greatly appreciated.
<sw**********@y ahoo.com> schrieb: I have a txt file which has a few lines of special characters:
This is A line from the text file:
٦?-ŧُ? ʍ?S o?ѥZ? ?~²ů 'ۣT^ б*'с^ ZS',,T ?ZЏ
When I use sr.ReadLine (where "sr As StreamReader"), it is not giving me this line at all, it gets cut and the characters are totally different.
'StreamReader' interprets the file as UTF-8 by default. Maybe the file has
been saved using another encoding such as Windows ANSI with the system's
default code page. Note that you can pass an encoding to 'StreamReader'' s
overloaded constructor. To obtain the system's ANSI encoding, use
'System.Text.En coding.Default' .
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Perfect, I get it!!!! Million thanks.
Herfried K. Wagner [MVP] wrote: <sw**********@y ahoo.com> schrieb: I have a txt file which has a few lines of special characters:
This is A line from the text file:
٦?-ŧُ? ʍ?S o?ѥZ? ?~²ů 'ۣT^ б*'с^ ZS',,T ?ZЏ
When I use sr.ReadLine (where "sr As StreamReader"), it is not giving me this line at all, it gets cut and the characters are totally different.
'StreamReader' interprets the file as UTF-8 by default. Maybe the file has been saved using another encoding such as Windows ANSI with the system's default code page. Note that you can pass an encoding to 'StreamReader'' s overloaded constructor. To obtain the system's ANSI encoding, use 'System.Text.En coding.Default' .
-- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/>
<sw**********@y ahoo.com> schrieb: Basically they are ASCII between 128 and 255. What should I be using, or how should I declare it in order to get those characters back?
ASCII is a 7-bit encoding, this means only character codes 0 through 127 are
defined. You may want to try 'System.Text.En coding.Default' for the
system's ANSI codepage or other encodings in 'System.Text.En coding'. Note
that 'Encoding.Unico de' means UTF-16.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: kaede |
last post by:
Hi all,
I am new to C# and currently writing a Nntp client to read article
from a chinese newsgroup. I am curious how to decode the chinese
character using streamreader and display it properly on Win2K and
WinXP?
I have tried the following:
// send XOVER commands to get the header XOVER 1234-1234
|
by: Astronomically Confused |
last post by:
using System;
using System.Collections;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Threading;
class HttpProcessor
{
private Socket s;
|
by: Keith Kingsley |
last post by:
I'm using a StreamReader to read in several lines from an ASCII file. I'd
like to know the StreamReader's "true" position-- that is, the number of
bytes into the file that the StreamReader has read. I thought about using
MyStreamReader.BaseStream.Position, but this always seems to return a
multiple of the StreamReader's buffer size (which seems natural-- as I
understand it the StreamReader reads from the underlying stream in discrete...
|
by: Arno |
last post by:
Hi,
I'm using TcpClient for communication between two PC running a small
piece
of software. The protocol used has been designed internally and is
HTTP
similar (command line, headers, body). A typical response in this
protocol
would be:
|
by: Joan Reddy |
last post by:
Can anyone tell me why this code doesn't work for setting the pointer to the
begining of a file stream?
This is driving me crazy.
At the end of Main1, sString2 is the second line of the file, as if the Seek
never worked.
Shouldn't sString1 and sString2 each contain the first line of the file?
To fix this (as in Main2), I need to create a new reader. Is this
documented behavior, or is this a bug??
| |
by: KenLee |
last post by:
help!!
I used StreamReader and StreamWrite.
the problem is it doesn't write all readline.
For example it read 100 line and write 51lines.
this is codes.
class kenlee{
private StreamWriter sw ;
private StreamReader sr;
private String line;
|
by: lord.zoltar |
last post by:
Hi, I'm having some trouble with a StreamReader.
I use a System.IO.StreamReader to read a text file and then print it.
If the user has selected a range of pages starting past the first page,
I have to make the StreamReader jump to some point in the file.
To make the StreamReader jump to where it should be, I use the
following code:
fReader.BaseStream.Seek(fileBookmark + (Me.reportTextWidth *
linesPerPage * startPage),...
|
by: Matt Bailey |
last post by:
I am writing an ASP page with a C# backend. This page uses a
StreamReader to input a file and pull out a specific section of the
text based on markers inside. While the code I have works, I get a 404
error on files larger than 10 mbs, which will be a common occurence. I
understand this might be a question better suited for an ASP forum, but
I was wondering if anyone out there knows of an alternative to the
StreamReader which will help...
|
by: Arpan |
last post by:
The contents of a text file are as follows:
The Quick Brown
Fox Jumped Over
The Lazy Dog.
Note that there isn't any space at the end of each of the 3 lines.
Now when I do this:
|
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...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 projectplanning, coding, testing, and deploymentwithout 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...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |