Click here to Skip to main content
15,896,726 members
Home / Discussions / C#
   

C#

 
AnswerRe: special character replacement Pin
PIEBALDconsult29-Jul-10 3:13
mvePIEBALDconsult29-Jul-10 3:13 
GeneralRe: special character replacement Pin
varsh1229-Jul-10 3:20
varsh1229-Jul-10 3:20 
GeneralRe: special character replacement Pin
PIEBALDconsult29-Jul-10 3:22
mvePIEBALDconsult29-Jul-10 3:22 
GeneralRe: special character replacement Pin
Keith Barrow29-Jul-10 3:36
professionalKeith Barrow29-Jul-10 3:36 
AnswerRe: special character replacement Pin
Luc Pattyn29-Jul-10 4:06
sitebuilderLuc Pattyn29-Jul-10 4:06 
GeneralRe: special character replacement Pin
varsh1229-Jul-10 4:49
varsh1229-Jul-10 4:49 
GeneralRe: special character replacement Pin
Sauro Viti29-Jul-10 5:19
professionalSauro Viti29-Jul-10 5:19 
GeneralRe: special character replacement Pin
Luc Pattyn29-Jul-10 7:43
sitebuilderLuc Pattyn29-Jul-10 7:43 
Hi,

much better now, I understand you happen to have strings that hold Unicode characters in their \u format (as accepted by the C# compiler), and need them to be interpreted. I wasn't able to locate a .NET class that really supports this, so the best I could come up with is:

static string DecodeUnicode(string s) {
    StringBuilder sb=new StringBuilder();
    while (s.Length!=0) {
        sb.Append((char)int.Parse(s.Substring(2, 4), NumberStyles.HexNumber));
        s=s.Substring(6);
    }
    return sb.ToString();
}


which only accepts strings that consist of groups of six characters (a backslash, a 'u', and 4 hex digits); you may choose to add checks and error handling.

It works for your example.
string s="\\u092A\\u094B\\u0937\\u093E\\u0939\\u093E\\u0930";
log(s);
s=DecodeUnicode(s);
log(s);


FWIW: I think you got yourself into trouble; most of the time, you should simply avoid having to do this, and have the compiler translate those \uXXXX sequences into single characters!

PS: I'm not sure what HttpUtility.HtmlEncode is doing for you.

Smile | :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.


GeneralRe: special character replacement Pin
varsh1230-Jul-10 19:30
varsh1230-Jul-10 19:30 
QuestionMessage Removed Pin
29-Jul-10 0:28
sush829-Jul-10 0:28 
AnswerRe: How to convert doc file to pdf file using itextsharp? PinPopular
OriginalGriff29-Jul-10 0:55
mveOriginalGriff29-Jul-10 0:55 
GeneralRe: How to convert doc file to pdf file using itextsharp? Pin
sush829-Jul-10 1:21
sush829-Jul-10 1:21 
GeneralRe: How to convert doc file to pdf file using itextsharp? Pin
Eddy Vluggen29-Jul-10 1:30
professionalEddy Vluggen29-Jul-10 1:30 
GeneralRe: How to convert doc file to pdf file using itextsharp? Pin
sush829-Jul-10 1:46
sush829-Jul-10 1:46 
GeneralRe: How to convert doc file to pdf file using itextsharp? Pin
Eddy Vluggen29-Jul-10 2:32
professionalEddy Vluggen29-Jul-10 2:32 
GeneralRe: How to convert doc file to pdf file using itextsharp? PinPopular
OriginalGriff29-Jul-10 1:35
mveOriginalGriff29-Jul-10 1:35 
AnswerRe: How to convert doc file to pdf file using itextsharp? Pin
Richard MacCutchan29-Jul-10 0:59
mveRichard MacCutchan29-Jul-10 0:59 
QuestionSmall Problem in Windows application.... Pin
Krishna Varadharajan29-Jul-10 0:25
Krishna Varadharajan29-Jul-10 0:25 
AnswerRe: Small Problem in Windows application.... Pin
Eddy Vluggen29-Jul-10 0:53
professionalEddy Vluggen29-Jul-10 0:53 
GeneralRe: Small Problem in Windows application.... Pin
Krishna Varadharajan29-Jul-10 1:26
Krishna Varadharajan29-Jul-10 1:26 
AnswerRe: Small Problem in Windows application.... Pin
Richard MacCutchan29-Jul-10 0:57
mveRichard MacCutchan29-Jul-10 0:57 
QuestionDos Copy Command Pin
M Riaz Bashir28-Jul-10 23:52
M Riaz Bashir28-Jul-10 23:52 
AnswerRe: Dos Copy Command Pin
Simon P Stevens29-Jul-10 0:16
Simon P Stevens29-Jul-10 0:16 
GeneralRe: Dos Copy Command Pin
M Riaz Bashir29-Jul-10 0:18
M Riaz Bashir29-Jul-10 0:18 
QuestionDisable Excel opening Message in C# [modified] Pin
Mugdha_Aditya28-Jul-10 20:15
Mugdha_Aditya28-Jul-10 20:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.