473,322 Members | 1,188 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

UTF8 encoding problem


I am having a problem preparing a UTF8 string for IPP (internet
printing protocol) transmission. Converting integers until 639 goes
well, but beyond this, in case of 640, results in an extra byte(?).
It shoot be 0x00, 0x00, 0x02 0x80 but I get : 00, 0x00, 0x02 0xc2
0x80.

Can somebody give me a hint, please?
private String Bytes4ToString(int fourbyte)
{

Byte[] temp=BitConverter.GetBytes(fourbyte);
char a=(char)temp[3];
char b=(char)temp[2];
char c=(char)temp[1];
char d=(char)temp[0];
StringBuilder result=new StringBuilder();
result.Append(a.ToString());
result.Append(b.ToString());
result.Append(c.ToString());
result.Append(d.ToString());

return result.ToString();

}

After this I send a stringbuilder instance "send" including this
"result" string to a webserver.

String send=build.ToString();

UTF8Encoding encoding=new UTF8Encoding();
Byte[]subdata= encoding.GetBytes(send);

TIA Gert


Nov 15 '05 #1
1 3974
SloppyCoder <ti******@hotmail.com> wrote:
I am having a problem preparing a UTF8 string for IPP (internet
printing protocol) transmission. Converting integers until 639 goes
well, but beyond this, in case of 640, results in an extra byte(?).
It shoot be 0x00, 0x00, 0x02 0x80 but I get : 00, 0x00, 0x02 0xc2
0x80.

Can somebody give me a hint, please?


You seem to be confusing character data and binary data. I very much
doubt that the printing protocol *really* expects its data to come as
UTF-8 encoded strings which themselves aren't really text but contain
unicode characters for binary values. I'd be very surprised if numbers
such as 129 are doing what you expect them to either.

You're converting into UTF-8 and back at the moment - do you have a
document describing what is actually expected at the other end? What
are *you* expecting?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #2

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

Similar topics

5
by: Richard Lewis | last post by:
Hi there, I'm having a problem with unicode files and ftplib (using Python 2.3.5). I've got this code: xml_source = codecs.open("foo.xml", 'w+b', "utf8") #xml_source = file("foo.xml",...
3
by: hunterb | last post by:
I have a file which has no BOM and contains mostly single byte chars. There are numerous double byte chars (Japanese) which appear throughout. I need to take the resulting Unicode and store it in a...
4
by: H Lee | last post by:
Hi, I'm an XML newbie, and not sure if this is the appropriate newsgroup to post my question, so feel free to suggest other newgroups where I should post this message if this is the case. I'm...
1
by: Frank Esser | last post by:
Hello! On a PC with German Codepage settings I want to get UTF8 out of string in my application. I use this function: Byte array = Encoding.UTF8.GetBytes("à"); When I look at the Unicode...
7
by: EmeraldShield | last post by:
We have an application that uses UTF8 everywhere to load / save / process documents. One of our clients is having a problem with BIG Encoded files being trashed after running through our app. ...
4
by: EmeraldShield | last post by:
(Dot Net 2 C# application - using Encoding.UTF8 with a StreamReader) I have a very strange problem that I cannot explain with a UTF8 Readline() although this could exist in other types of encoding,...
2
by: darrel | last post by:
I was having issues before with my XML being sent to the browser as UTF16. Via my XmlTextWriter, was able to fix this by explicitely setting the encoding to UTF8: Dim objX As New...
4
by: weheh | last post by:
I'm developing a cgi-bin application that must be unicode sensitive. I'm striving for a UTF8 implementation. I'm running python 2.3 on a development machine (windows xp) and a server (windows xp...
39
by: alex | last post by:
I've converted a latin1 database I have to utf8. The process has been: # mysqldump -u root -p --default-character-set=latin1 -c --insert-ignore --skip-set-charset mydb mydb.sql # iconv -f...
1
by: Alexey Smirnov | last post by:
On Apr 23, 8:36 am, jmr <ko...@free.frwrote: What is your Encoding.Default? Use Encoding.UTF8 instead, or set it in the globalization tag of the web.config file.
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.