I am working on a Japanese File and I have no knowledge of the language. The file is encoded in S-JIS. Now, I am supposed to convert the contents into UTF-8 so that the content looks like Japanese. And here I am completely blank. I tried the following code that I found somewhere on Internet but no luck:
I am using the following code to decode base 64 and quoted printable encoded messages. It works well for all the charset's except for quoted printable chinese (Charsets: GB18030, GB2312). When I tried to decode, I am getting '?' as output. provide on this code or any other code that decodes all types of encoded string?
My problem is with .Net Http/Uri libraries not being able to decode or unescape this character sequence: "Hi%E1". Neither Uri.UnescapeDataString nor HttpUtility.UrlDecode can do it.
Although I have a solution to get around this problem ( http://stackoverflow.com/questions/1221849/url-decoding-confusion ) I would like to understand why it is failing.
The 1st test here throws an exception! The second just fails.
There is nothing in the docs to indicate that UnescapeDataString or UrlDecode are restricted to character sets or any reason why these tests would fail. However, from testing, it would appear that HttpUtility assumes UTF-8 (or some other) encoding.
The Java equivalent works! Probably because it allows an encoding to be set.
URLDecoder.decode("Hi%E1","windows-1252"); // this works btw, ie passes tests
Which looks like a very sensible move considering the .Net work-around (see URL above)
Are the .Net implementations of these methods just crap and .Net devs just have to write their own - or am I missing something?
BTW Everything I know of in IIS set to UTF-8, and Chinese/Japanese characters show fine, so I don't yet know how it could it be that this URI consists of windows-1252 encoded characters. If I could fix the URI to contain UTF-8 encoding, that would be a better way of fixing this.
in asp.net mvc 3 preview 1 automaticly encodes html, is there an alternative way to let there be html?think of this cenario:@view.BestSitesEver.Replace("stackoverflow", "<h1>StackOverflow</h1>")That would just print out: <h1>stackoverflow</h1>
I want to read .dat file using Asp.Net C#. I have some details in my .dat file and I want to decode it and need to display on my web page. I already tried to decode it but it was not working properly. Its showing boxes in my web page.
Edit I'd misunderstood what was happening here.. there is a POST send, then receive back a result, then the URL string which I'm seeing here is part of the the query string... so I can't decode what this really is, as it is encoded by the payment gateway people and not me.
What is the best way to encode the url in Hyperlink without writing code behind. I have many uses and I would like to do it in the Hyperlink statemeent if possible. Some thing such as the following would be great: (This does not work)
I have a list of character that display fine in WebBrowser in the form of encoded characters such as € � ... But when posting these characters onto server to I realized that HttpUtility.HtmlDecode cannot convert them to characters as browser did, they all become space.
text = System.Web.HttpUtility.HtmlDecode("€");
I expect it to return € but it return space instead. The same thing happen for some other characters as well.
I am trying to render html encoded string that is stored in SQL Server into human readable form. The HttpUtility.Decode does not decode the text that is rendered in between the open tag and closing tag of any input tag (ie. TextBox or TextArea or Select) in my ASPX page. However, HttpUtility.Decode works fine if the text is not in an input tag. The following is my test code. For example, the value of AdmitDX field in database is "Someone's comment" which is "Someone's comment" when decoded. The first two code nuggets <%%> will show as "Someone's comment" and the thrid code nugget will show "Someone's comment".
<!-- the following two lines have html encoded text, instead of html decoded text --> <%= Html.TextArea("AdmitDX", HttpUtility.HtmlDecode(thisTransfer.AdmitDX))%> <%= Html.TextBox("AdmitDX", HttpUtility.HtmlDecode(thisTransfer.AdmitDX)) %> <!-- the next line works fine --> Test = <%= HttpUtility.HtmlDecode(thisTransfer.AdmitDX) %>
I have saved all data that comes through Input boxes using AntiXss.HtmlEncode(the text from in put box); Now all texts in my databse are HtmlEncoded So now i want to show them in text boxesSo iave to decode that ? How can i decode a text that is encoded using AntiXss
on VWD 2005 this code works fine, but on 2008 it says I haven't created an instance of the object. I want to convert the object connString (a connection string) into a string.
'This acceses the virtual directory web.config file for connection strings 'We have to convert the object to a connection string Dim rootWebConfig As System.Configuration.Configuration rootWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/VirtualDirec") Dim connString As System.Configuration.ConnectionStringSettings connString = rootWebConfig.ConnectionStrings.ConnectionStrings("ConnectString1") Dim strConnString As String = connString.ToString().......
I'm concatenating a string in codebehind to use in a sql select statement.
in aspx
<asp:Label ID="LabelHidden" runat="server" Visible="False"></asp:Label> SelectCommand="SELECT * FROM [Data] WHERE [ActivityName] IN (@ActivityName) AND ([ID] = @ID)" <SelectParameters> <asp:ControlParameter ControlID="DropDownList_Employees" Name="ID" PropertyName="SelectedValue" Type="Int32" /> <asp:ControlParameter ControlID="LabelHidden" Name="ActivityName" Type="String" /> </SelectParameters> in codebehind foreach (ListItem li in ListBox_Activities.Items) { if (li.Selected) { queryBuilder += li + "', "; } queryBuilder = queryBuilder.Substring(0, queryBuilder.Length - 1); LabelHidden.Text = queryBuilder;
When i run the code it comes up blank. I did a query trace and it seems to be running as
exec sp_executesql N'SELECT * FROM [Data] WHERE [ActivityName] IN (@ActivityName) AND ([ID] = @ID)',N'@EmployeeID int,@ActivityName nvarchar(50)',@EmployeeID=4,@ActivityName=N'Production Technical Support'', Tools Development'','
with exta "'s
How can i format the queryBuilder string correctly in my code?
 //Read string contents using stream reader and convert html to parsed conent var parsedHtmlElements = HTMLWorker.ParseToList(new StringReader(contents), null);  //Get each array values from parsed elements and add to the PDF document foreach (var htmlElement in parsedHtmlElements) pdfDoc.Add(htmlElement as IElement);  //Close your PDF pdfDoc.Close();  Response.ContentType = "application/pdf";  //Set default file Name as current datetime Response.AddHeader("content-disposition",
[Code] ....
Error: Input string was not in a correct format. Contents in html file giving error ...
At debug time I would like to see what are the keys in my InitParams collection - I can't seem to be able to list them.
EDIT:As Jon suggests below, this might be a bug within the Silverlight debugger. To reproduce, just create a new Silverlight Application within Visual Studio 2010 and just edit code
{ public partial class MainPage : UserControl { [code]...