473,944 Members | 6,018 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to UTF-8 encode a string?


hello,
i'm doing utf-8 encoding the following way.
string message;

UTF8Encoding utf8 = new UTF8Encoding();

Byte[] encodedBytes = utf8.GetBytes(m essage);

message = encodedBytes.To String();

can someone correct me?

many thanks

JJ
Apr 24 '06
28 95165
> Another question if remote end is a webservice, why can't you make web
reference to it and then communicate via stub?
--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com

Hi Vadmyn,

this is a B2B scenario and i may not publish the complete System.Net.Trac e
as it contain very confidential info.

But here is the last bit . I doubt you can get any usefull hint from it.

Mnay thanks anyway

System.Net Information: 0 : [8036]
ConnectStream#5 0223079::Connec tStream(Buffere d 24 bytes.)
System.Net Information: 0 : [8036] Associating HttpWebRequest# 4878312 with
ConnectStream#5 0223079
System.Net Information: 0 : [8036] Associating HttpWebRequest# 4878312 with
HttpWebResponse #45011781
System.Net Verbose: 0 : [8036] ConnectStream#5 0223079::Read()
System.Net.Sock ets Verbose: 0 : [8036] Socket#13575069 ::Dispose()
System.Net Verbose: 0 : [8036] Data from ConnectStream#5 0223079::Read
System.Net Verbose: 0 : [8036] 00000000 : 3C 68 34 3E 41 63 63 65-73 73 20
44 65 6E 69 65 : <h4>Access Denie
System.Net Verbose: 0 : [8036] 00000010 : 64 3C 2F 68 34 3E 0D 0A-
: d</h4>..
System.Net Verbose: 0 : [8036] Exiting ConnectStream#5 0223079::Read() ->
24#24
System.Net Verbose: 0 : [8036] ConnectStream#5 0223079::Read()
System.Net Verbose: 0 : [8036] Exiting ConnectStream#5 0223079::Read() ->
0#0
System.Net Error: 0 : [8036] Exception in the
HttpWebRequest# 4878312::EndGet Response - The remote server returned an
error: (401) Unauthorized.
Apr 24 '06 #21
jens Jensen wrote:
Another question if remote end is a webservice, why can't you make web
reference to it and then communicate via stub?
this is a B2B scenario and i may not publish the complete System.Net.Trac e
as it contain very confidential info.

But here is the last bit . I doubt you can get any usefull hint from it.


Well, I don't know:
System.Net Error: 0 : [8036] Exception in the
HttpWebRequest# 4878312::EndGet Response - The remote server returned an
error: (401) Unauthorized.


That seems to indicate your problem is to do with authorization more
than anything else.

Jon

Apr 24 '06 #22
>
Another question if remote end is a webservice, why can't you make web
reference to it and then communicate via stub?
--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com


This is no proper webserivce. It just does xml over https.


Apr 24 '06 #23
Hello, jens!

jJ> This is no proper webserivce. It just does xml over https.

As Jon pointed out, the problem you have is connected with authorization.

Look at the docs for
HttpWebRequest. Credentials property.
--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
Apr 24 '06 #24
Thus wrote Mike,
I am presuming that the problem is that the bytes are correct but the
remote service doesn't recognize them as being UTF-8. Try adding

req.ContentEnco ding = encoding;


That's HttpRequest as of ASP.NET fame and doesn't apply here ;-)
--
Joerg Jooss
ne********@joer gjooss.de
Apr 24 '06 #25

"Joerg Jooss" <ne********@joe rgjooss.de> wrote in message
news:94******** *************** ***@msnews.micr osoft.com...
Thus wrote Mike,
I am presuming that the problem is that the bytes are correct but the
remote service doesn't recognize them as being UTF-8. Try adding

req.ContentEnco ding = encoding;


That's HttpRequest as of ASP.NET fame and doesn't apply here ;-)


What type is "req", then?
Apr 25 '06 #26
Mike Schilling wrote:
That's HttpRequest as of ASP.NET fame and doesn't apply here ;-)


What type is "req", then?


HttpWebRequest, I suspect.

Jon

Apr 25 '06 #27
Thus wrote Mike,
"Joerg Jooss" <ne********@joe rgjooss.de> wrote in message
news:94******** *************** ***@msnews.micr osoft.com...
Thus wrote Mike,
I am presuming that the problem is that the bytes are correct but
the remote service doesn't recognize them as being UTF-8. Try
adding

req.ContentEnco ding = encoding;

That's HttpRequest as of ASP.NET fame and doesn't apply here ;-)

What type is "req", then?


You came up with that line of code, you tell me ;-)

Must have been System.Net.Http WebRequest -- don't have the OP at hand anymore.

Cheers,
--
Joerg Jooss
ne********@joer gjooss.de
Apr 26 '06 #28

"Joerg Jooss" <ne********@joe rgjooss.de> wrote in message
news:94******** *************** ***@msnews.micr osoft.com...
Thus wrote Mike,
"Joerg Jooss" <ne********@joe rgjooss.de> wrote in message
news:94******** *************** ***@msnews.micr osoft.com...
Thus wrote Mike,

I am presuming that the problem is that the bytes are correct but
the remote service doesn't recognize them as being UTF-8. Try
adding

req.ContentEnco ding = encoding;

That's HttpRequest as of ASP.NET fame and doesn't apply here ;-)

What type is "req", then?


You came up with that line of code, you tell me ;-)
Must have been System.Net.Http WebRequest -- don't have the OP at hand
anymore.


The OP didn't show the declaration, which is why I asked.

But I'm sure you (and Jon) are right.
Apr 26 '06 #29

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

Similar topics

3
3391
by: aa | last post by:
Is it OK to include an ANSI file into a UTF-8 file?
27
5176
by: EU citizen | last post by:
Do web pages have to be created in unicode in order to use UTF-8 encoding? If so, can anyone name a free application which I can use under Windows 98 to create web pages?
38
5772
by: Haines Brown | last post by:
I'm having trouble finding the character entity for the French abbreviation for "number" (capital N followed by a small supercript o, period). My references are not listing it. Where would I find an answer to this question (don't find it in the W3C_char_entities document). -- Haines Brown brownh@hartford-hwp.com
48
4682
by: Zenobia | last post by:
Recently I was editing a document in GoLive 6. I like GoLive because it has some nice features such as: * rewrite source code * check syntax * global search & replace (through several files at once) * regular expression search & replace. Normally my documents are encoded with the ISO setting. Recently I was writing an XHTML document. After changing the encoding to UTF-8 I used the
16
6193
by: lawrence | last post by:
I was told in another newsgroup (about XML, I was wondering how to control user input) that most modern browsers empower the designer to cast the user created input to a particular character encoding. This arose in answer to my question about how to control user input. I had complained that I had users who wrote articles in Microsoft Word or WordPerfect and then input that to the web through a textarea box on a form I'd created. I've...
1
15636
by: stevelooking41 | last post by:
Can someone explain why I don't seem unable to use document.write to produce a valid UTF-8 none breaking space sequence (Hex: C2A0) ? I've tried everyway I've been able to find to tell the browser I'm trying to print UTF-8 and still no luck. I'd like the first 2 tries to match the second two tries as far as output. <HTML> <meta http-equiv="Content-Type" content="application/x-script; charset=UTF-8">
1
2027
by: David Bertoni | last post by:
Hi all, I'm trying to resolve what appears to me an inconsistency in the XML 1.0 recommendation involving entities encoding in UTF-16 and the requirement for a byte order mark. Section 4.3.3 has the following text: http://www.w3.org/TR/REC-xml/#charencoding
7
12178
by: Jimmy Shaw | last post by:
Hi everybody, Is there any SIMPLE way to convert from UTF-16 to UTF-32? I may be mixed up, but is it possible that all UTF-16 "code points" that are 16 bits long appear just the same in UTF-32, but with zero padding and hence no real conversion is necessary? If I am completely wrong and some intricate conversion operation needs to take place, can anyone give me some primer on the subject?
10
19616
by: Jed | last post by:
I have a form that needs to handle international characters withing the UTF-8 character set. I have tried all the recommended strategies for getting utf-8 characters from form input to email message and I cannot get it to work. I need to stay with classic asp for this. Here are some things I tried: 'CDONTS Call msg.SetLocaleIDs(65001)
35
4385
by: Bjoern Hoehrmann | last post by:
Hi, For a free software project, I had to write a routine that, given a Unicode scalar value U+0000 - U+10FFFF, returns an integer that holds the UTF-8 encoded form of it, for example, U+00F6 becomes 0x0000C3B6. I came up with the following. I am looking for a more elegant solution, that is, roughly, faster, shorter, more readable, ... while producing the same ouput for the cited range. unsigned int
0
9973
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,...
0
11136
jinu1996
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...
1
11310
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,...
0
10677
tracyyun
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...
0
9870
agi2029
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...
0
7399
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();...
0
6093
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...
1
4924
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
3
3520
bsmnconsultancy
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.