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|0020028 20327|Data Switch|EA|00030 900|00000
36-EPSON7753|01034 3600003|Ø*Ù†Ù…Ø ¨Ø± طابعه 500/570|EA|00001200 |00000
ER-270019|01338827 0019|بقتال الشارع|EA |00019900|00000
while index file for this products file contains the indexes of each barcode:
format: BarcodeHeader (space) RecordStartPosi tion
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_FmtdFil e.DiscardBuffer edData();
this.sr_FmtdFil e.BaseStream.Po sition = 0;
this.sr_FmtdFil e.BaseStream.Se ek(index , SeekOrigin.Begi n);
while( (record = this.sr_FmtdFil e.ReadLine()) != null )
{
//Code to get desired record.
}
Please help how to handle Arabic Text(Unicode Character) in file pointer
movement.
Arif. 4 2010
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.co m
"Arif" <Ar**@discussio ns.microsoft.co m> wrote in message
news:3E******** *************** ***********@mic rosoft.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|0020028 20327|Data Switch|EA|00030 900|00000 36-EPSON7753|01034 3600003|????? ????? 500/570|EA|00001200 |00000 ER-270019|01338827 0019|????? ??????|EA|00019 900|00000
while index file for this products file contains the indexes of each barcode: format: BarcodeHeader (space) RecordStartPosi tion
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_FmtdFil e.DiscardBuffer edData(); this.sr_FmtdFil e.BaseStream.Po sition = 0; this.sr_FmtdFil e.BaseStream.Se ek(index , SeekOrigin.Begi n);
while( (record = this.sr_FmtdFil e.ReadLine()) != null ) { //Code to get desired record. }
Please help how to handle Arabic Text(Unicode Character) in file pointer movement.
Arif.
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|0020028 20327|Data Switch|EA|00030 900|00000 36-EPSON7753|01034 3600003|Ø*Ù†Ù…Ø ¨Ø± طابعه 500/570|EA|00001200 |00000 ER-270019|01338827 0019|بقتال الشارع|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) RecordStartPosi tion
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
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|0020028 20327|Data Switch|EA|00030 900|00000 36-EPSON7753|01034 3600003|Ø*Ù†Ù…Ø ¨Ø± طابعه 500/570|EA|00001200 |00000 ER-270019|01338827 0019|بقتال الشارع|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) RecordStartPosi tion
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
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.co m
"Arif" <Ar**@discussio ns.microsoft.co m> wrote in message news:3E******** *************** ***********@mic rosoft.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|0020028 20327|Data Switch|EA|00030 900|00000 36-EPSON7753|01034 3600003|????? ????? 500/570|EA|00001200 |00000 ER-270019|01338827 0019|????? ??????|EA|00019 900|00000
while index file for this products file contains the indexes of each barcode: format: BarcodeHeader (space) RecordStartPosi tion
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_FmtdFil e.DiscardBuffer edData(); this.sr_FmtdFil e.BaseStream.Po sition = 0; this.sr_FmtdFil e.BaseStream.Se ek(index , SeekOrigin.Begi n);
while( (record = this.sr_FmtdFil e.ReadLine()) != null ) { //Code to get desired record. }
Please help how to handle Arabic Text(Unicode Character) in file pointer movement.
Arif. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 "file.tell() and file.seek() in order to
navigate through a file in order to print specific lines (for example, every
5th line). Allow me to illustrate by example:
|
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 by 6. I
mean, ptr+6. Another way to ask the same question is how do you move
to the 3rd record in a file (considering that the file is made up of
records).
I told the interviewer that we could do a seek to move to the
specific byte. At that...
|
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 unsigned 8 byte integers. Naturally this
broke my code which uses fseek(), and can only offset by
longs, which on the target OS is a 4 byte integer.
There are ways around this using OS calls, but
as far as I can tell the C99 standard offers no...
|
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 abstract class
and an interface..
By some reasons, I want to move the "," close to "difference", I want it
looks like this
|
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 use the seek() like this:
StreamReader r;
.......
r.BaseStream.seek(.....);
| |
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: 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 two problems
with this...I tried opening the file for both writing and reading with:
std::fstream file("budget.txt", std::ios_base::in | std::ios_base::out
| std::ios_base::app);
if(!file)
std::cerr << "Error opening file!" << std::endl;
|
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 the recordset opens a table. When I
write
Set rst = db.OpenRecordset("MyTable",dbOpenTable, dbReadOnly)
I get an error. I believe it's invalid operation or invalid parameter, I'm
|
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...
|
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,...
|
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: 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...
|
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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |