473,324 Members | 2,193 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,324 software developers and data experts.

Seek() don't move pointer to exact location in file have Arabic Te

My programs searches the header of input barcode in index file. Get the
record position next to Barcode header. Then moves the file pointer of
products file to reach that record.

My products file contains records as follows:

9N-F1T0153|002002820327|Data Switch|EA|00030900|00000
36-EPSON7753|010343600003|Ø*نمبر طابعه 500/570|EA|00001200|00000
ER-270019|013388270019|بقتال الشارع|EA|00019900|00000

while index file for this products file contains the indexes of each barcode:
format: BarcodeHeader (space) RecordStartPosition

00200282 0
01034360 55
01338827 121

for first two records file pointer is working file and i can get whole
record by ReadLine(). But from the 3rd record i don't get the whole record
but a part. i realized that this is due to Arabic Text(Unicode Characters)
that exists in second record and therefore file pointer

If the file don't have Arabic Text(Unicode Character) then everything works
fine.

Code Snippet:

this.sr_FmtdFile.DiscardBufferedData();
this.sr_FmtdFile.BaseStream.Position = 0;
this.sr_FmtdFile.BaseStream.Seek(index , SeekOrigin.Begin);

while( (record = this.sr_FmtdFile.ReadLine()) != null )
{
//Code to get desired record.
}

Please help how to handle Arabic Text(Unicode Character) in file pointer
movement.

Arif.
Nov 17 '05 #1
4 1993
Arif,

If you have a combination of unicode and ascii characters in the file,
then you will not be able to use a reader. As a matter of fact, I don't see
how you will be able to tell if the characters are unicode or ASCII unless
only that specific field is unicode and it is predictable when this is so.

Regardless, you will not be able to use a stream reader for this. You
will have to go through the file and get the bytes yourself, converting them
when appropriate.

Or, you should just write the whole file in unicode characters to begin
with, and then you can read the lines as you were doing before.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Arif" <Ar**@discussions.microsoft.com> wrote in message
news:3E**********************************@microsof t.com...
My programs searches the header of input barcode in index file. Get the
record position next to Barcode header. Then moves the file pointer of
products file to reach that record.

My products file contains records as follows:

9N-F1T0153|002002820327|Data Switch|EA|00030900|00000
36-EPSON7753|010343600003|????? ????? 500/570|EA|00001200|00000
ER-270019|013388270019|????? ??????|EA|00019900|00000

while index file for this products file contains the indexes of each
barcode:
format: BarcodeHeader (space) RecordStartPosition

00200282 0
01034360 55
01338827 121

for first two records file pointer is working file and i can get whole
record by ReadLine(). But from the 3rd record i don't get the whole record
but a part. i realized that this is due to Arabic Text(Unicode Characters)
that exists in second record and therefore file pointer

If the file don't have Arabic Text(Unicode Character) then everything
works
fine.

Code Snippet:

this.sr_FmtdFile.DiscardBufferedData();
this.sr_FmtdFile.BaseStream.Position = 0;
this.sr_FmtdFile.BaseStream.Seek(index , SeekOrigin.Begin);

while( (record = this.sr_FmtdFile.ReadLine()) != null )
{
//Code to get desired record.
}

Please help how to handle Arabic Text(Unicode Character) in file pointer
movement.

Arif.

Nov 17 '05 #2
Arif wrote:
My programs searches the header of input barcode in index file. Get the
record position next to Barcode header. Then moves the file pointer of
products file to reach that record.

My products file contains records as follows:

9N-F1T0153|002002820327|Data Switch|EA|00030900|00000
36-EPSON7753|010343600003|Ø*نمبر طابعه 500/570|EA|00001200|00000
ER-270019|013388270019|بقتال الشارع|EA|00019900|00000
And how *exactly* are those records encoded? That's the important bit -
if you can work out the encoding of the file, that would help a lot.

See http://www.pobox.com/~skeet/csharp/unicode.html for more about
encodings.
while index file for this products file contains the indexes of each barcode:
format: BarcodeHeader (space) RecordStartPosition

00200282 0
01034360 55
01338827 121


How has that been calculated? If it's done on the number of characters
(rather than the number of bytes) then it won't work with
variable-length encodings (such as UTF-8).

Jon

Nov 17 '05 #3
Much thanks Jon,

i was calculating on number of characters. now i test with number of bytes
and it is working fine.

again much thanks Jon for understanding my problem and giving me an idea for
solution.

Arif.

"Jon Skeet [C# MVP]" wrote:
Arif wrote:
My programs searches the header of input barcode in index file. Get the
record position next to Barcode header. Then moves the file pointer of
products file to reach that record.

My products file contains records as follows:

9N-F1T0153|002002820327|Data Switch|EA|00030900|00000
36-EPSON7753|010343600003|Ø*نمبر طابعه 500/570|EA|00001200|00000
ER-270019|013388270019|بقتال الشارع|EA|00019900|00000


And how *exactly* are those records encoded? That's the important bit -
if you can work out the encoding of the file, that would help a lot.

See http://www.pobox.com/~skeet/csharp/unicode.html for more about
encodings.
while index file for this products file contains the indexes of each barcode:
format: BarcodeHeader (space) RecordStartPosition

00200282 0
01034360 55
01338827 121


How has that been calculated? If it's done on the number of characters
(rather than the number of bytes) then it won't work with
variable-length encodings (such as UTF-8).

Jon

Nov 17 '05 #4
Thanks Nicholas,

I am sure that there was some mistake in telling my problem. I confused you
with combination of ASCII and Unicode characters because that time i was also
confused with my problem. Sorry for that.
But Jon Skeet understood my problem exactly. He give me idea to do indexing
on number of bytes while i was doing on number of characters.

Arif.

"Nicholas Paldino [.NET/C# MVP]" wrote:
Arif,

If you have a combination of unicode and ascii characters in the file,
then you will not be able to use a reader. As a matter of fact, I don't see
how you will be able to tell if the characters are unicode or ASCII unless
only that specific field is unicode and it is predictable when this is so.

Regardless, you will not be able to use a stream reader for this. You
will have to go through the file and get the bytes yourself, converting them
when appropriate.

Or, you should just write the whole file in unicode characters to begin
with, and then you can read the lines as you were doing before.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Arif" <Ar**@discussions.microsoft.com> wrote in message
news:3E**********************************@microsof t.com...
My programs searches the header of input barcode in index file. Get the
record position next to Barcode header. Then moves the file pointer of
products file to reach that record.

My products file contains records as follows:

9N-F1T0153|002002820327|Data Switch|EA|00030900|00000
36-EPSON7753|010343600003|????? ????? 500/570|EA|00001200|00000
ER-270019|013388270019|????? ??????|EA|00019900|00000

while index file for this products file contains the indexes of each
barcode:
format: BarcodeHeader (space) RecordStartPosition

00200282 0
01034360 55
01338827 121

for first two records file pointer is working file and i can get whole
record by ReadLine(). But from the 3rd record i don't get the whole record
but a part. i realized that this is due to Arabic Text(Unicode Characters)
that exists in second record and therefore file pointer

If the file don't have Arabic Text(Unicode Character) then everything
works
fine.

Code Snippet:

this.sr_FmtdFile.DiscardBufferedData();
this.sr_FmtdFile.BaseStream.Position = 0;
this.sr_FmtdFile.BaseStream.Seek(index , SeekOrigin.Begin);

while( (record = this.sr_FmtdFile.ReadLine()) != null )
{
//Code to get desired record.
}

Please help how to handle Arabic Text(Unicode Character) in file pointer
movement.

Arif.


Nov 17 '05 #5

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

Similar topics

3
by: Pernell Williams | last post by:
Hi all: I am new to Python, and this is my first post (and it won't be my last!), so HELLO EVERYONE!! I am attempting to use "xreadlines", an outer loop and an inner loop in conjunction with...
31
by: Arvind Varma Kalidindi | last post by:
Hi, I was asked this question in an interview recently. "How do you move to the 6th byte in a file?" ... My thinking would be to find the data types in the file, set a base pointer and advance it...
5
by: David Mathog | last post by:
I recently ran into a problem where a data file downloaded from another site contained more than 4Gb of data and so the index file to items within that data went from unsigned 4 byte integers to...
0
by: Hai Nguyen | last post by:
Hi Everyone I'm building a C# console application. I need to write data from a text file. The text is something look like this "...From a C++ view there's no difference , between an...
11
by: Tiger | last post by:
We can use seek() in the FileStream class,as we know. But I found that seek() is not work correctly in StreamReader. Who can tell me how to use seek() correctly in StreamReader? thanks a lot! I...
2
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...
2
by: Eric Lilja | last post by:
Hello, I'm writing a simple program that upon start-up needs to open a text file and read a value on the last line. Then all other accesses to the file will be writes (at the end of it). I'm having...
59
by: Rico | last post by:
Hello, I have an application that I'm converting to Access 2003 and SQL Server 2005 Express. The application uses extensive use of DAO and the SEEK method on indexes. I'm having an issue when...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.