473,734 Members | 2,317 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problems using Enconding.UTF8. GetString(byte[]), values above 127 == ""

Like the subject said. I have an byte array and want to save them in a
text file with UTF8 encoding. However when an element in the byte array
is above 127 the GetString method ignores the value and I get an
incorrect string.

Anyone who knows what the problem is?

Jan 30 '06 #1
1 3526
PrettySne...@gm ail.com wrote:
Like the subject said. I have an byte array and want to save them in a
text file with UTF8 encoding. However when an element in the byte array
is above 127 the GetString method ignores the value and I get an
incorrect string.

Anyone who knows what the problem is?

Yes - you're trying to treat arbitrary binary data as if it were a
valid UTF8 string, which it's not. To save binary data in a text file,
you're best to use something like Base64. See Convert.ToBase6 4String
and Convert.FromBas e64String.


Jan 30 '06 #2

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

Similar topics

by: Barry | last post by:
Hi all, I've noticed a strange error on my website. When I print a capital letter P with a dot above, using & #7766; it appears correctly, but when I use P& #0775 it doesn't. The following capital letters all work correctly - B C D F G M S T with the diacritical marker &#_0775. Why am I having a problem with P?
by: bq | last post by:
Hello, Two questions related to floating point support: What C compilers for the wintel (MS Windows + x86) platform are C99 compliant as far as <math.h> and <tgmath.h> are concerned? What wintel compilers support a 16-byte "long double" (with 33 decimal digits of accuracy) including proper printf() support. I found some compilers that did support "long double", but theirs was an 8-byte or 10-byte or 12-byte type with accuracy the...
by: Pablo Gutierrez | last post by:
I have a C# method that reads Binary data (BLOB type) from a database and returns the data an array of bytes (i.e byte outbyte = new byte;). The BLOB column is saved into the database by a C program (UNIX) as an array of "struct point" where struct point //C structure { int Time; //32 bits
by: _BNC | last post by:
I've converted " byte" to "byte *" at times, using 'unsafe' and fixed { .... }, but the reverse does not seem to work. In this case, a C++ DLL returns a byte * and a length. What is the best way to convert these to straight C#-compatible straight " byte" arrays? PS: The C++ DLL is actually managed and I have access to the source. Perhaps there is a simpler syntax for doing the conversion there, and returning a C# compatible array...
by: Chris Wood | last post by:
In C#, I am calling a method implemented in Managed C++ that returns an array of booleans. This method in turn calls unto unmanaged C++ code that returns an unsigned byte array, which is implicitly casted to a bool __gc . However, in my client C# app, when I examine this array in the locals window, it shows "bool" as the type of the array and "byte" as the type of each element. If I try this in Whidbey beta, it shows "bool {byte}" and...
by: Kevin Pedersen | last post by:
Hello, I am using an editable datagrid. After I save the changes the datagrid shows the old values. I've read the posts about the Page_Load and not binding the datagrid each time. The SQL that is being sent to the database is correct and the changes are eventually being made. If I refresh the page after the update then the new values appear. I noticed that when I put a breakpoint in my update handler everything works fine. When I take...
by: JW | last post by:
Ok, I hope this is something easy... but I have been staring at this for way too long. I have the following query ( ODBC conn setup to MySQL ): SELECT MonthName(dateOfOrder) as month, SUM(cost) as sales FROM orderInfo, imagesInOrder WHERE orderInfo.id=imagesInOrder.order_id Group By Month(dateOfOrder) which returns the following when I iterate over the OdbcDataReader:
by: Rich | last post by:
Hello, I have to create a table in an Access mdb (remotely) on the fly. Create Table tbl1(fld1 Integer, fld2 varchar(10), fld3...) Then I have to insert data: Insert Into tbl1 Values(" & val1 & ", '" & val2 & "',...")"
by: Rubenintx | last post by:
Need some help with this code / Using UNIX. The goals is to read a big file (2,000,000) lines, using fork() to create children to help in the process. I am able to get the program (C++) running and this is what it does: 1) creates the number of children the user indicates 2) can read the number lines in the TXT file 3) tells how many lines each child will read This is how I understand what the program will do and I want to make...
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: 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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
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: 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: 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...

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.