473,402 Members | 2,050 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,402 software developers and data experts.

quoted string in .Net (@="\u...") convert to unicode

I have this situation:
string h = "#u00d8";
h = h.Replace("#","\\"); // =h = @"\u00d8"
WriteLine(h); //="\u00d8"

But I wishes to have this situation:
h = "\u00d8";
WriteLine(h); //="Ø"

How can I convert a qouted string to a string object so that it can be
parsed by the .Net framework when I call WriteLine (or something
similar).

Conclution: I do not want the Replace() method to add the qouted string
marker (@)!! How can I escape the escape character (@)? :)

Nov 21 '06 #1
4 6610
Jorgen <jo*************@gmail.comwrote:
I have this situation:
string h = "#u00d8";
h = h.Replace("#","\\"); // =h = @"\u00d8"
WriteLine(h); //="\u00d8"

But I wishes to have this situation:
h = "\u00d8";
WriteLine(h); //="Ø"

How can I convert a qouted string to a string object so that it can be
parsed by the .Net framework when I call WriteLine (or something
similar).

Conclution: I do not want the Replace() method to add the qouted string
marker (@)!! How can I escape the escape character (@)? :)
Replace isn't adding the @. The debugger is just displaying it.

A "quoted string" *is* a string object. Now, if you want that to be
parsed for things like \uxxxx, I *believe* you'll have to do that
yourself. (I don't know of any classes in the framework which do it for
you.)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Nov 21 '06 #2
c = (Char)UInt16.Parse(g.Value.Substring(2),
NumberStyles.AllowHexSpecifier);

"Jorgen" wrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
I have this situation:
string h = "#u00d8";
h = h.Replace("#","\\"); // =h = @"\u00d8"
WriteLine(h); //="\u00d8"

But I wishes to have this situation:
h = "\u00d8";
WriteLine(h); //="Ø"

How can I convert a qouted string to a string object so that it can be
parsed by the .Net framework when I call WriteLine (or something
similar).
Conclution: I do not want the Replace() method to add the qouted string
marker (@)!! How can I escape the escape character (@)? :)
Nov 21 '06 #3
Jorgen wrote:
I have this situation:
string h = "#u00d8";
h = h.Replace("#","\\"); // =h = @"\u00d8"
WriteLine(h); //="\u00d8"
This won't do what you think it will because the \u (and indeed all
escape sequences) are only interpreted on string literals! If you
replace the value of a string with "\\", you're just going to have a
string with a slash as it's value.

string s = "\u00d8";
WriteLine(s); //Should show the char you want because of the string
litereal

string s = "#u00d8";
s = sReplace("#","\\")
WriteLine(s); //Results in "\u00d8" being written (without the quotes)

Nov 21 '06 #4

Ben Voigt skrev:
c = (Char)UInt16.Parse(g.Value.Substring(2),
NumberStyles.AllowHexSpecifier);
Thanks that was what I wanted. It worked fine.

Nov 22 '06 #5

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

Similar topics

4
by: Julia | last post by:
Hi, I need to convert unicode string to ansi string Thanks in adavance.
1
by: ghostnguyen | last post by:
Hi all I read data from a website and encoding in UTF8. So the result I had like this: và resumes trực tiế How can convert the "ự" (and these string like this) to Unicode character.
5
by: wanghz | last post by:
Hello, everyone. I have a problem when I'm processing unicode strings. Is it possible to get the 8bit-string representation of any unicode string? Suppose I get a unicode string: a =...
9
by: a | last post by:
I need to write a regular expression to match a quoted string in which the double quote character itself is represented by 2 double quotes. For example: "beginning ""nested quoted string"" end"...
2
by: excite | last post by:
I am trying to write a long string into a txt file, the string includes some backslash, looks like: 'd:\#########\#######\####### d:\######\####\####\### d:\###\###\' then I got a error saying...
6
by: Aneesh E Warrier | last post by:
How can I convert Unicode Codepoint (dec) value to ASCII char? For example: 49324 is 사 a Korean alphabet, and I want to convert it to ASCII letter. Thanks!
9
by: vaskar | last post by:
I have got one problem in VB.NET 2005 using unicode I want to add two numbers in vb.net 2005 through UNICODE I didn't know how to convert UNICODE string to integer. I hope you can solve my...
0
by: Jean-Paul Calderone | last post by:
On Mon, 5 May 2008 16:05:08 +0200, Simon Posnjak <sposnjak@gmail.comwrote: You need to provide some more information about `some_module.some_thing´. How is it implemented? What Python type does...
7
by: Laszlo Nagy | last post by:
Peter Bulychev wrote: Please be more specific. There is no general solution. Unicode can handle latin, cyrilic (russian), chinese, japanese and arabic characters in the same string. There are...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
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,...
0
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...
0
Oralloy
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,...
0
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...
0
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...
0
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,...
0
isladogs
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...

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.