How to convert back a string that have converted to byte[] using
System.Text.Enc oding.UTF8.GetB ytes()
string StringData = "This is a string";
byte[] ConvertedString = System.Text.Enc oding.UTF8.GetB ytes(StringData );
Now, how can I convert ConvertedString to "This is a string" string again? 8 2050
"FrzzMan" <Fr************ ***@vnOCzone.co m> wrote in message
news:Os******** ********@TK2MSF TNGP10.phx.gbl. .. How to convert back a string that have converted to byte[] using System.Text.Enc oding.UTF8.GetB ytes()
string StringData = "This is a string"; byte[] ConvertedString = System.Text.Enc oding.UTF8.GetB ytes(StringData );
Now, how can I convert ConvertedString to "This is a string" string again?
System.Text.Enc oding.UTF8.GetS tring
Erik
FrzzMan wrote: How to convert back a string that have converted to byte[] using System.Text.Enc oding.UTF8.GetB ytes()
string StringData = "This is a string"; byte[] ConvertedString = System.Text.Enc oding.UTF8.GetB ytes(StringData );
Now, how can I convert ConvertedString to "This is a string" string again?
string System.Text.Enc oding.UTF8.GetS tring(byte[]);
--
Tom Porterfield
MS-MVP MCE http://support.telop.org
Please post all follow-ups to the newsgroup only.
FrzzMan wrote: How to convert back a string that have converted to byte[] using System.Text.Enc oding.UTF8.GetB ytes()
string StringData = "This is a string"; byte[] ConvertedString = System.Text.Enc oding.UTF8.GetB ytes(StringData );
Now, how can I convert ConvertedString to "This is a string" string again?
Oops sorry, I didn't know there's GetString method... sry...
..NET GetBytes() and GetString() didn't work right with UTF-8 charset.
My following code prove that...
string Data = "UTF-8 string"; // <-- Insert some *long* UTF-8 string
byte[] DataBytes = System.Text.Enc oding.UTF8.GetB ytes(Data);
string BackConvert = System.Text.Enc oding.UTF8.GetS tring(DataBytes );
System.IO.Strea mWriter File = System.IO.File. CreateText("tes t.txt");
File.Write(Data + "\n" + BackConvert);
File.Close();
Wait a lil, see the attached text file, open it with your browser and
set browser text encoder to UTF-8, you'll see the different...
FrzzMan <Fr************ ***@vnOCzone.co m> wrote: .NET GetBytes() and GetString() didn't work right with UTF-8 charset.
My following code prove that...
string Data = "UTF-8 string"; // <-- Insert some *long* UTF-8 string byte[] DataBytes = System.Text.Enc oding.UTF8.GetB ytes(Data); string BackConvert = System.Text.Enc oding.UTF8.GetS tring(DataBytes );
System.IO.Strea mWriter File = System.IO.File. CreateText("tes t.txt"); File.Write(Data + "\n" + BackConvert); File.Close();
Wait a lil, see the attached text file, open it with your browser and set browser text encoder to UTF-8, you'll see the different...
Um, I doubt it, to be honest. You'll need to give us a sample string to
show us what you mean.
To check that the strings are the same, you could just use
Console.WriteLi ne (Data==BackConv ert);
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
I doubt it, too... but I did try and it didn't work... in the last post
I forgot to attach the result with sample string, my fault...
In this post I attached the result file of the test, and I tried to
System.Console. WriteLine(Data == BackConvert) before, it give me a False.
You can try it yourself... use the first line in the attached file as
the sample string...
Jon Skeet [C# MVP] wrote: FrzzMan <Fr************ ***@vnOCzone.co m> wrote:
.NET GetBytes() and GetString() didn't work right with UTF-8 charset.
My following code prove that...
string Data = "UTF-8 string"; // <-- Insert some *long* UTF-8 string byte[] DataBytes = System.Text.Enc oding.UTF8.GetB ytes(Data); string BackConvert = System.Text.Enc oding.UTF8.GetS tring(DataBytes );
System.IO.Str eamWriter File = System.IO.File. CreateText("tes t.txt"); File.Write(Da ta + "\n" + BackConvert); File.Close( );
Wait a lil, see the attached text file, open it with your browser and set browser text encoder to UTF-8, you'll see the different...
Um, I doubt it, to be honest. You'll need to give us a sample string to show us what you mean.
To check that the strings are the same, you could just use
Console.WriteLi ne (Data==BackConv ert);
miniLZO -- mini subset of the LZO real-time data compression library Đây l* tiếng Việt, nén th* coi có được không n*o... Đây l* tiếng Việt, nén th* coi có được không n*o... Đây l* tiếng Việt, nén th* coi có được không n*o... Đây l* tiếng Việt, nén th* coi có được không n*o... Đây l* tiếng Việt, nén th* coi có được không n*o... Đây l* tiếng Việt, nén th* coi có được không n*o... Đây l* tiếng Việt, nén th* coi có được không n*o...
miniLZO -- mini subset of the LZO real-time data compression library Đây l* tiếng Việt, nén th* coi có được không n*o... Đây l* tiếng Việt, nén th* coi có được không n*o... Đây l* tiếng Việt, nén th* coi có được không n*o... Đây l* tiếng Việtꀜҥnén th* coi cóꁦҥược không n*o... Đây l* tiếng Việt, nén ꀰҥ* coi có được không n*o... Đây l* tiếng ꁶҥệt, nén th* coi có được không n*o... Đây l* tiếng Việt, nén th* coi có được không ꂍҥo...
FrzzMan <Fr************ ***@vnOCzone.co m> wrote: I doubt it, too... but I did try and it didn't work... in the last post I forgot to attach the result with sample string, my fault...
In this post I attached the result file of the test, and I tried to System.Console. WriteLine(Data == BackConvert) before, it give me a False.
You can try it yourself... use the first line in the attached file as the sample string...
You haven't actually really attached a file - just cut and paste it.
Please email me an example and I'll have a look at it.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Thanks, .rar file mailed... I still can't get it working...
Jon Skeet [C# MVP] wrote: FrzzMan <Fr************ ***@vnOCzone.co m> wrote:
I doubt it, too... but I did try and it didn't work... in the last post I forgot to attach the result with sample string, my fault...
In this post I attached the result file of the test, and I tried to System.Consol e.WriteLine(Dat a == BackConvert) before, it give me a False.
You can try it yourself... use the first line in the attached file as the sample string...
You haven't actually really attached a file - just cut and paste it. Please email me an example and I'll have a look at it. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Swarup |
last post by:
I am reading a file (txt, xml, gif, ico, bmp etc) byte by byte and filling
it into a byte arry. Now i have to convert it into a string to store it in
the database.
I use
System.Text.UnicodeEncoding enc = new System.Text.UnicodeEncoding();
now i am using enc.GetString(value) and the value retured is one byte less
if the size of the byte array is Odd. In case of files having even number
of bytes, the convertion is happening correctly and...
|
by: Hako |
last post by:
I try this command:
>>> import string
>>> string.atoi('78',16)
120
this is 120 not 4E.
Someone can tell me how to convert a decimal number to hex number? Can
print A, B, C,DEF.
Thank you.
|
by: Ricardo Quintanilla |
last post by:
i have a code that sends data to a socket listening over as400 platform,
the socket responds to me as a "byte array".
then i need to convert the "byte array" into a string.
the problem is that the data converted from the byte array into a string
, is not what i expect.
example:
- the data returned from the socket is (byte array)
"Usuario Sin Atribuciones Para Esta Función"
|
by: Jan Eliasen |
last post by:
Hi
I have a string, which I must convert into another string and have it
utf-8 encoded.
My current code looks like this;
Both vDataIn and vDataOut are Objects (parameters to a function-call),
and vDataIn contains a string, and that is also what vDataOut must
contain when I am done.
|
by: Charles Law |
last post by:
I thought this was going to be straight forward, given the wealth of
conversion functions in .NET, but it is proving more convoluted than
imagined.
Given the following
<code>
Dim ba(1) As Byte
Dim b As Byte
| |
by: Nikolay Petrov |
last post by:
How can I convert DOS cyrillic text to Unicode
|
by: moondaddy |
last post by:
I'm writing an app in vb.net 1.1 and need to convert a byte array into a
string, and then from a string back to a byte array.
for example
Private mByte() as New Byte(4){11,22,33,44}
Now how do I convert it to:
dim myStr as string = "11,22,33,44"
|
by: cmdolcet69 |
last post by:
Public ArrList As New ArrayList
Public bitvalue As Byte()
Public Sub addvalues()
Dim index As Integer
ArrList.Add(100)
ArrList.Add(200)
ArrList.Add(300)
ArrList.Add(400)
ArrList.Add(500)
|
by: Debadatta Mishra |
last post by:
Introduction
In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information inside an image, hide your complete image as text ,search for a particular image inside a directory, minimize the size of the image. However this is not a new concept, there is a concept called Steganography which enables to conceal your secret...
|
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, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets 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: 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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 projectplanning, coding, testing, and deploymentwithout 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: 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.
| |
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...
| |