.NET Framework Bookmark and Share   
 index > .NET Base Class Library > How to deal with a uri which contains a non English character?
 

How to deal with a uri which contains a non English character?

If my current uri has some unicode-string like string local = @"E:\サwォ’アフィ.txt"; and then I use a Uri to wrap it as Uri uri = new Uri(local). But in the debug window, it shows me as follows..

-uri{file:///E:/サwォ’アフィ;txt}System.Uri
AbsolutePath"E:/%E3%82%B5%EF%BD%97%E3%82%A9%E2%80%99%E3%82%A2%E3%83%95%E3%82%A3;txt"string
AbsoluteUri"file:///E:/%E3%82%B5%EF%BD%97%E3%82%A9%E2%80%99%E3%82%A2%E3%83%95%E3%82%A3;txt"string

Itlooks like the property AbsolutePath and AbsoluteUri cannot show the expeceted Japanese, but only uri.ToString() does, and I do not see there is any Encoding related parameter in the Uri constructor, so if I still want my method to use AbsolutePath/AbsoluteUri under differrent lanuage input, how can I deal with it? Any one has the idea?


Thanks in advance,
Jovi





Jovi Shen
This is by design. Review this web page for the kind of characters that are allowed in a URI.

Hans Passant.
nobugz

The WIKI shows that the there are 2 kinds of URI precent-encoding. For reserved character, such as !@#$, etc, and for unserved character, such as my scenario. So what the the URI properties actaully returns is just the precent-encoding value, but cannot show the literal Japanese - by degisn for this point, so the only way is to use ToString to get the actual content.

Is my understanding correct based on your comment?

Jovi Shen
Yes.
Hans Passant.
nobugz

You can use google to search for other answers

Custom Search

More Threads

• BinaryFormatter Serialize/Deserialize a Class with new members added
• TextWriterTraceListener Permission error
• Access is denied using WMI on systems with high loads
• Creating Font or FontFamily...
• Save my file with my extension
• Change papersource
• Server Error in '/Financing' Application
• Dealing with implicit meaning, collections, Dictionary
• Can I use reflection to find out what methods a method is calling?
• Security - Data Access Best Practices