I need to search through a binary file to find a specific string and then
replace it with another string. However the
System.Text.Enc oding.ASCII.Get String method i originally used seems to do
some character conversion. I also tried using UTF7-8 and Unicode
conversions, but the output is still converted. How do i get past this?
Thanks in advance,
Kasper Hansen 5 2283
"Kasper Hansen" <ka********** @h-hansen.dk> schrieb I need to search through a binary file to find a specific string and then replace it with another string. However the System.Text.Enc oding.ASCII.Get String method i originally used seems to do some character conversion.
ASCII = 7bit = characters 0 - 127 only
I also tried using UTF7-8 and Unicode conversions, but the output is still converted. How do i get past this?
Which character encoding has been used to write into the file? You'd have to
know this first. If 1 character = 1 byte it's probably ANSI encoding
(System.Text.En coding.Default) .
--
Armin http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
> Which character encoding has been used to write into the file? You'd have
to know this first. If 1 character = 1 byte it's probably ANSI encoding (System.Text.En coding.Default) .
Well, i just want the output to be exactly the same as the input. 0xFF =
0xFF and 0x7F = 0x7F and so on. I also tried the default encoding, but it
didn't work either. Any other suggestions?
/Kasper Hansen
* "Kasper Hansen" <ka********** @h-hansen.dk> scripsit: I need to search through a binary file to find a specific string and then replace it with another string. However the System.Text.Enc oding.ASCII.Get String method i originally used seems to do some character conversion. I also tried using UTF7-8 and Unicode conversions, but the output is still converted. How do i get past this?
You may want to use 'Encoding.Defau lt' to read the file with the
currently used codepage.
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
> You may want to use 'Encoding.Defau lt' to read the file with the currently used codepage.
Sorry - you're both right. I overlooked a spot where i did the conversion
once more.
Thanks alot.
/Kasper Hansen
"Kasper Hansen" <ka********** @h-hansen.dk> schrieb Which character encoding has been used to write into the file? You'd have to know this first. If 1 character = 1 byte it's probably ANSI encoding (System.Text.En coding.Default) .
Well, i just want the output to be exactly the same as the input. 0xFF = 0xFF and 0x7F = 0x7F and so on. I also tried the default encoding, but it didn't work either. Any other suggestions?
Could you please show an example how you read/convert/display chars?
If you want to convert to Char/String, you must know the source
encoding because the byte value(s) must be converted to Unicode as
Chars are always Unicode encoded.
--
Armin This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Steve Mauldin |
last post by:
I came across an example in the MSDN documentation using RC2 encryption(the
link to the article is at the end of this message). When I tried it I had a
problem with getting back the same length string that I sent into it. After
working on Debugging the code I found two problems. One was in the
statement fromEncrypt = New Byte(encrypted.Length) {} where both
FromEncrypt and encrypted are both byte arrays and encrypted's length is 24....
|
by: Bill Cunningham |
last post by:
I've been reading the C standard online and I'm puzzled as to what multibyte
chars are. Wide chars I believe would be characters for languages such as
cantonese or Japanese. I know the ASCII character set specifies that each
character such as 'b' or 'B' is an 8 bit character. So what's a multibyte
character?
Also how would you use the function parameter main (char argc, char
**argv) if that's correct?
Bill
|
by: Alexei A. Frounze |
last post by:
Hi all,
I have a question regarding the gcc behavior (gcc version 3.3.4).
On the following test program it emits a warning:
#include <stdio.h>
int aInt2 = {0,1,2,4,9,16};
int aInt3 = {0,1,2,4,9};
|
by: Dennis Myrén |
last post by:
Hi.
Is there a way to utilize the great primitive data type
formatting routines available in .NET without working with
strings?
I want a byte directly rather than a string.
I think it is unfortunate that i have to walk via System.String to do that.
For instance, from an integer of value 123, i want:
|
by: pkumar |
last post by:
How to convert this byte array to string
byte b=new byte;
Is there any function or I need read one by one and build the string
thanks
| |
by: Richard506 |
last post by:
If you take this Byte Arra
Dim bytes() As Byte = {
207, 224, 135, 161, 253, 233, 111, 110, 99, 111, 100, 105, 110, 103,
32, 69, 120, 97, 109, 112, 108, 101
and write the byte array to disk
FileOpen(2, "f:\aaapicture_album\result.txt", OpenMode.Binary
FilePut(2, bytes
FileClose(2
then convert it into a string --->
|
by: Jeff Stewart |
last post by:
I wrote the following function to accomodate a legacy driver function
that only accepted VB6-style strings. The driver expects a string
that represents an array of binary data to be sent over USB.
Private Function byteArrayToString(ByVal byteArray() As Byte) As
String
Dim returnString As String = New String("")
Dim i As Integer
For i = 0 To byteArray.Length - 1
returnString += Chr(byteArray(i))
|
by: ThunderMusic |
last post by:
Hi,
I have to go from Byte() to String, do some processing then reconvert the
String to byte() but using ascii format, not unicode.
I currently use a stream to write the char() (BinaryWriter.Write) from the
string (String.ToCharArray), then use Stream.ToArray to convert everything
to byte(). It works most of the time, but it happens that an error tells me
something like "Additional information: Caractère de substitution faible
trouvé...
|
by: chaitali.pats |
last post by:
Hi ,
I have implemented MD5 in C language . I am getting an output of 32
bits Hexadecimal number . for example :
83a80d3ca057492f0ce99ac1db8dced0
I need to convert this string same to 16 byte array.
Can anyone help me ?
|
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: 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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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: 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: 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: 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
| |