Hello,
I am trying to read the contents of 01.bin (unicode) into a String, to
modify it and finally to write it back into an other file named 02.bin.
If the file really contains "a b c", then everything is replaced properly.
But the finally output looks like "ÿþb b c".
There is that prefix ÿþ. I assume that it is always printed when you work
with unicode files but I do not know how to get rid of it.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim enc As System.Text.Encoding = System.Text.Encoding.Unicode
Dim a As String =
Microsoft.VisualBasic.FileIO.FileSystem.ReadAllTex t("01.bin", enc)
Dim b As String = Replace(a, "abc", "bbc", 1, -1)
Microsoft.VisualBasic.FileIO.FileSystem.WriteAllTe xt("02.bin", b,
False, enc)
End Sub 4 1843
Kenny,
I think that you first have to decide in what code your outputfile should
be.
Some links,
General http://www.microsoft.com/globaldev/r...ce/cphome.mspx
OS systems http://www.microsoft.com/globaldev/r...ocversion.mspx
I hope this helps a little bit?
Cor
"kenny" <ke***@discussions.microsoft.com> schreef in bericht
news:1F**********************************@microsof t.com... Hello, I am trying to read the contents of 01.bin (unicode) into a String, to modify it and finally to write it back into an other file named 02.bin.
If the file really contains "a b c", then everything is replaced properly. But the finally output looks like "ÿþb b c". There is that prefix ÿþ. I assume that it is always printed when you work with unicode files but I do not know how to get rid of it.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim enc As System.Text.Encoding = System.Text.Encoding.Unicode
Dim a As String = Microsoft.VisualBasic.FileIO.FileSystem.ReadAllTex t("01.bin", enc)
Dim b As String = Replace(a, "abc", "bbc", 1, -1)
Microsoft.VisualBasic.FileIO.FileSystem.WriteAllTe xt("02.bin", b, False, enc)
End Sub
"kenny" <ke***@discussions.microsoft.com> schrieb: I am trying to read the contents of 01.bin (unicode) into a String, to modify it and finally to write it back into an other file named 02.bin.
If the file really contains "a b c", then everything is replaced properly. But the finally output looks like "ÿþb b c". There is that prefix ÿþ. I assume that it is always printed when you work with unicode files but I do not know how to get rid of it.
It's the UTF-BOM. 'Encoding.Unicode' is actually UTF-16. You can avoid
creating the BOM as follows:
\\\
Dim enc As Encoding = New UnicodeEncoding(True, False)
Dim sw As New StreamWriter(..., enc)
///
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
thank you! it works.
@Cor Ligthert:
i think it should be Unicode :)
"Herfried K. Wagner [MVP]" wrote: It's the UTF-BOM. 'Encoding.Unicode' is actually UTF-16. You can avoid creating the BOM as follows:
\\\ Dim enc As Encoding = New UnicodeEncoding(True, False) Dim sw As New StreamWriter(..., enc) ///
-- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/>
Do you (or others) know, by chance, if there is also a way to avoid
insertion of the Byte Order Mark (BOM), using the binary formatter? I
have alway been curious about that....
-tom
Herfried K. Wagner [MVP] ha scritto: "kenny" <ke***@discussions.microsoft.com> schrieb: I am trying to read the contents of 01.bin (unicode) into a String, to modify it and finally to write it back into an other file named 02.bin.
If the file really contains "a b c", then everything is replaced properly. But the finally output looks like "ÿþb b c". There is that prefix ÿþ. I assume that it is always printed when you work with unicode files but I do not know how to get rid of it.
It's the UTF-BOM. 'Encoding.Unicode' is actually UTF-16. You can avoid creating the BOM as follows:
\\\ Dim enc As Encoding = New UnicodeEncoding(True, False) Dim sw As New StreamWriter(..., enc) ///
-- 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: Michael Weir |
last post by:
I'm sure this is a very simple thing to do, once you know how to do it, but
I am having no fun at all trying to write utf-8 strings to a unicode file.
Does anyone have a couple of lines of code...
|
by: webdev |
last post by:
lo all,
some of the questions i'll ask below have most certainly been discussed
already, i just hope someone's kind enough to answer them again to help
me out..
so i started a python 2.3...
|
by: JSM |
last post by:
Hi,
I am just trying to port an existing simple encryption routine to C#. this
routine simply adds/substracts 10 ascii characters to each character in a
text file (except quotes). The routine...
|
by: Charles F McDevitt |
last post by:
I'm trying to upgrade some old code that used old iostreams.
At one place in the code, I have a path/filename in a wchar_t string
(unicode utf-16).
I need to open an ifstream to that file. ...
|
by: Nikolay Petrov |
last post by:
How can I convert DOS cyrillic text to Unicode
| |
by: Jeff |
last post by:
Hi -
I'm setting up a streamreader in a VB.NET app to read a text file and
display its contents in a multiline textbox.
If I set it up with System.Text.Encoding.Unicode, it reads a unicode...
|
by: Donn Ingle |
last post by:
Hello,
I hope someone can illuminate this situation for me.
Here's the nutshell:
1. On start I call locale.setlocale(locale.LC_ALL,''), the getlocale.
2. If this returns "C" or anything...
|
by: Mudcat |
last post by:
In short what I'm trying to do is read a document using an xml parser
and then upload that data back into a database. I've got the code more
or less completed using xml.etree.ElementTree for the...
|
by: tshad |
last post by:
I have a program in 2005 that is reading a text file removing text and then
writing it back out again. It removes lines that start with PRINT.
This program has worked fine for months. Now all...
|
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,...
|
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...
| |
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,...
|
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...
|
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...
|
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,...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |