473,466 Members | 1,367 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Exporting unicode characters to a file (at this point I dont carewhat type of file)

We purchased som software for encoding a barcode. We want to
automate the process of converting a number to a readable barcode.

However, I am having a few issues.

The file that the barcode needs to be appended to is dbf file type,
I wrote a dbf writer so adding data on the fly is not a problem, the
problem is
trying to get the correct encoding. The barcode utility that we
purchased
works fine. However, when I write the values of the barcode to a dbf,
txt, csv, the
values are not identical. Here is the data comparision.

Original value of the field that is being converted to a barcode:

41864-00001~

the conversion value is: (value generated by the barcode utility that
we purchased):

ÍIvÈ4-0ÇÂ!È~}Î <--- note this is the value I need to be
exported for barcode scanning.
I use a binary writer to export the values to a dbf file and when i
open the dbf to view it, I get the following values:

'using System.Text.ASCIIEncoding.UTF8.GetBytes(_importCod e)

ÍIvÈ4-0ÇÂ!
'using System.Text.ASCIIEncoding.UTF7.GetBytes(_importCod e)
+AM0-Iv+AMg-4-


I've also tried writing it to text file, but still the same issue. We
currently are using a vba module to export the file however
this is not done using automation. Any advice?
Jul 21 '08 #1
2 2801
"JimmyKoolPantz" <ko*******@gmail.comschrieb:
>The file that the barcode needs to be appended to is dbf file type,
I wrote a dbf writer so adding data on the fly is not a problem, the
problem is
trying to get the correct encoding. The barcode utility that we
purchased
works fine. However, when I write the values of the barcode to a dbf,
txt, csv, the
values are not identical. Here is the data comparision.

Original value of the field that is being converted to a barcode:

41864-00001~

the conversion value is: (value generated by the barcode utility that
we purchased):

ÍIvÈ4-0ÇÂ!È~}Î <--- note this is the value I need to be
exported for barcode scanning.

I use a binary writer to export the values to a dbf file and when i
open the dbf to view it, I get the following values:
Post the code you use to read and write the values to the file.

Note that .NET strings are always UTF-16 strings, and reading text with a
certain encoding will only guaranteed to work if it has been written using
the same encoding.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Jul 22 '08 #2
On Jul 22, 12:53*pm, "Herfried K. Wagner [MVP]" <hirf-spam-me-
h...@gmx.atwrote:
"JimmyKoolPantz" <kohl.m...@gmail.comschrieb:


The file that the barcode needs to be appended to is dbf file type,
I wrote a dbf writer so adding data on the fly is not a problem, the
problem is
trying to get the correct encoding. *The barcode utility that we
purchased
works fine. *However, when I write the values of the barcode to a dbf,
txt, csv, the
values are not identical. Here is the data comparision.
Original value of the field that is being converted to a barcode:
41864-00001~
the conversion value is: (value generated by the barcode utility that
we purchased):
ÍIvÈ4-0ÇÂ!È~}Î * * * ** *<--- note this is the value I need to be
exported for barcode scanning.
I use a binary writer to export the values to a dbf file and when i
open the dbf to view it, I get the following values:

Post the code you use to read and write the values to the file.

Note that .NET strings are always UTF-16 strings, and reading text with a
certain encoding will only guaranteed to work if it has been written using
the same encoding.

--
*M S * Herfried K. Wagner
M V P *<URL:http://dotnet.mvps.org/>
*V B * <URL:http://dotnet.mvps.org/dotnet/faqs/>- Hide quoted text -

- Show quoted text -
I've been trying to figure this out all day. I've tried exporting the
file as a dbf, CSV, and Text and still nothing seems to be working.
One thing I did figure out(I think) is. when creating a textfile
using a filestream in .net. The default encoding is UTF-8. So when I
converted the text file to a .csv file and opened it up in excel,
excel recognized the BOM as a non unicode file, so that is why the
characters were not being displayed correctly. If I save the file
with the encoding type of unicode then the unicode characters would
display correctly. However, each line would be displayed into one
cell. Which was not good.

Another thing I tried was changing the encoding when declaring the
file stream and then create a tab text file which looked good on my
side, however, this did not look good at the printer.
Now im back trying to insert it into a dbf file. Here is some of the
code I am working with now.

I left most the code out, however what im basically doing is opening
a dbf file, filtering thru each record, and if the field name is
IMPORTCODE I take the value in that field and then encode the value
using a 3rd party dll. No problem with the dlll. IF the field name is
SCANCODE then I write the values out to the dbf file.

example in .net the _scancode = "ÍIvÈ4-0ÇÂ!È~}Î "
when i open the dbf file using excel I get the value = "═Iv╚4-0╟┬!╚~}"
if I open the file in ultra Edit I get the value = ÍIvÈ4-0ÇÂ!È~}

However, when the printing software opens the file they get the same
thing I see in excel which looks like a corrupted barcode.
Private fs_Reader As FileStream
Dim br As BinaryReader = Nothing
Dim bw As BinaryWriter = Nothing

fs_Reader = New FileStream(_filepath, FileMode.Open)
br = New BinaryReader(fs_Reader)
bw = New BinaryWriter(fs_Reader, System.Text.Encoding.Unicode)

For inum As Integer = 0 To _recordCount - 1
If (al(int) = "IMPORTCODE") Then
_importCode = GetImportCode(temp)
_scanCode = System.Text.Encoding.Unicode.GetBytes(_importCode)

ElseIf (al(int) = "SCANCODE") Then
Mark = fs_Reader.Position - Field_Length
bw.Seek(Mark, SeekOrigin.Begin)
bw.Write(_scanCode, 0, 13)
end if
Next



Jul 22 '08 #3

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

Similar topics

5
by: Dave Smithz | last post by:
Hi There, I have a PHP script that sends an email with attachment and works great when provided the path to the file to send. However this file needs to be on the same server as the script. ...
1
by: JJ | last post by:
Hi, usually, I'm not using MS servers, but I have a big problem with a Access table. I should create a web application for a Historical Dipartment. They have create a populated a Access...
3
by: RWK | last post by:
I'm trying to figure out how to verify that the file trying to be uploaded exists. On my page if I type in the name of a file that doesn't exist it get's uploaded as a file with 0 bytes. When...
1
by: Brian Henry | last post by:
When I use the file upload control <input type = file> and try to upload an exe file it errors, how do i get it to allow exe file uploads so I can display a frendly warrning message about they...
3
by: Maris Janis Vasilevskis | last post by:
Hi, I create a binary file on client side using ActiveX. Now, I need to upload it. First idea - hidden Input type=file Does not work, because value is read only. A quickly made working...
2
by: ssriram | last post by:
Is there a way to apply style to form field input type="file" (file upload component) If so, how? Thanks, Sunitha Sriram -- ssriram
9
by: Roger Withnell | last post by:
I am building a website in Russian. What options do I have to make the "Browse" button display in other languages? Thanking you in anticipation. Posted Via Usenet.com Premium Usenet...
6
by: Gorksha | last post by:
How to upload a file without using browse button provided by <input type=file > tag in html..
19
by: VUNETdotUS | last post by:
Firefox showed me a security error when I was copying a value of file field object into new DOM created input file field. Can I do something about it? Thanks.
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
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:
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...
1
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
tracyyun
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...
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.