encoding

Best way to put user input into generated javascript?

Hello, I need for someone to be able to put some text into a page and then this gets sent to the server, saved in the database, and else where this text is put into a javascript variable. Basically like this: Write("var myVar=\""+MyData+"\";"); What is the best way of escaping this data? Is there anything out there already to deal wi...

Explanation of JAXB error: Invalid byte 1 of 1-byte UTF-8 sequence

We're parsing an XML document using JAXB and get this error: [org.xml.sax.SAXParseException: Invalid byte 1 of 1-byte UTF-8 sequence.] at javax.xml.bind.helpers.AbstractUnmarshallerImpl.createUnmarshalException(AbstractUnmarshallerImpl.java:315) What exactly does this mean and how can we resolve this?? We are executing the code as: ...

Save programatically UTF-8 and C#

How to save programatically a file in UTF-8 with Signature 65001? ...

Python encoding for pipe.communicate

I'm calling pipe.communicate from Python's subprocess module from Python 2.6. I get the following error from this code: from subprocess import Popen pipe = Popen(cwd) pipe.communicate( data ) For an arbitrary cwd, and where data that contains unicode (specifically 0xE9): Exec. exception: 'ascii' codec can't encode character u'\x...

Java InputStream encoding/charset

Running the following (example) code import java.io.*; public class test { public static void main(String[] args) throws Exception { byte[] buf = {-27}; InputStream is = new ByteArrayInputStream(buf); BufferedReader r = new BufferedReader( new InputStreamReader(is, "ISO-8859-1")); Str...

Can I safely interpret ISO-8859-1 strings as Win1252 when parsing e-mail?

I need to support decoding ISO-8859-1 in my e-mail client. Specifically sometimes messages contain attaches that have filenames starting with "?iso-8859-1?". Wikipedia says ISO-8859-1 is pretty much the same as Windows 1252. I already have good tested code for decoding Win1252. Can I just use it directly and expect no problems? ...

Passing HTML using JSON

Hi All, I'm passing Data using JSON to iPhone and iPad. One Field of Data is HTML. The problem is the encoding. Here's what I get back: > "GadgetHTML": "<strong>Hello</strong> > from Catworld<br />\n<img alt=\"\" > src=\"http://www.iconarchive.com/icons/fasticon/ifunny/128/dog-icon.png\" > />", The \ are killing me. The \n does not ...

[iPhone app] Inserting special char un NSString for URL use

Hi, I'm using HTTP connection to share data with my JSON server. I use URLs like "MyServlet?param1=value1" and so on... I'm now facing a problem with one of my servlet (I can't change it because some other views are using it) : The servlet is working with a syntax including those symbols "{" and "}". The exact syntax is {(value1_va...

VB.NET encoding one character wrong

I have a byte array that I'm encoding to a string: Private Function GetKey() As String Dim ba() As Byte = {&H47, &H43, &H44, &H53, &H79, &H73, &H74, &H65, &H6D, _ &H73, &H89, &HA, &H1, &H32, &H31, &H36} Dim strReturn As String = Encoding.ASCII.GetString(ba) Return strReturn End Function Then I wri...

Unable to decode hex values in javascript tooltip

Hi all, I have quite the process that we go through in order to display some e-mail communications in our application. Trying to keep it as general as possible... -We make a request to a service via XML -Get the XML reply string, send the string to a method to encode any invalid characters as follows: public static String convertUT...

MS Word DDE: What does destroy my encoding?

I'm facing a problem with a MS Word DDE Automation controlled by our CRM system. The setup Base for the document created is a Word .dot template which fires a macro on Document.New. Inside this macro I create a .Net component registered for COM. Set myCOMObject = CreateObject("MyCOMObject") The component pulls some data from a datab...

headers already sent displays after moving files from one server to another

hey there! I have a project running on dreamhost hosting and it's working fine, but since DH has been getting really slow I'm moving the project to my new dedicated server. The thing is that after I move all of my file over to the new dedicated (ubuntu 8.4) I get see warnings all over the place telling me that the headers had been alre...

Are HTML entities necessary for anything besides escaping?

Obviously &lt; and &gt; are necessary for escaping user input. But is there any reason to use, say, &trade; instead of ™? ...

Is it possible to Html Encode content that may or may not alreayd be encoded cleanly?

Hi all, I'm using ASP.Net 4.0 with MVC 2. I'm recieving user content that may or may not be Html Encoded already. I've read http://weblogs.asp.net/scottgu/archive/2010/04/06/new-lt-gt-syntax-for-html-encoding-output-in-asp-net-4-and-asp-net-mvc-2.aspx which was interesting but what I need is a way to ensure the content is encoded withou...

Base X string encoding

I'm looking for a routine that will encode a string (stream of bytes) into an arbitrary base/alphabet (like base64 encoding but I get to choose the alphabet). I've seen a few routines that do base X encoding for a number, but not for a string. ...

mime decode pdf quoted-printable

Hi, I've been building a simple ticket system and it's all done and working except for when it receives PDF files via email that have been sent using quoted-printable encoding. I've tried using quoted_printable_decode(), the quoted-printable.decode stream filter, the later just created an empty file. I've also tried using $input = preg_...

Parsing mail subject with inline specified encoding

Hi, I'm trying to parse Email Subject which have encoding specified in format itself. I get the format and imagine how this can be done, but maybe there is any free .Net solution available already so I wouldn't waste time on it? Here is an example of subject I want to parse: =?ISO-8859-13?Q?Fwd=3A_Dvira=E8iai_vasar=E0_vagiami_da=FEniau...

[Asp.Net MVC] Encoding a character

Hi, I am experiencing some weird encoding behaviour in my ASP.NET MVC project. In my Site.Master there is <div class="logo"> <a href="<%=Url.Action("Index", "Win7")%>"><%= Html.Encode("Windows 7 Tutoriál") %></a></div> which translates to the resulting page as <div class="logo"> <a href="/">Windows 7 Tutoriál</a></d...

javascript. handling odd characters in encoded string

I have gotten a value, encoded like so: %3Cp%3E%0AGlobal%20Business%20Intensive%20Course%20%u2013% I noticed that one of the characters seems to be encoded in a different manner at the end, the %u2013. It appears to be some form of unicode character, but it is causing me to get URI malformed errors. is there a way to replace these wi...

Using NSXMLParser to extract attributes that are URL encoded?

Hello, I am trying to use NSXMLParser on the iPhone to parse a string that contains HTML, similar to the HTML shown below... <html><head><title>Working...</title></head><body><form method="POST" name="hiddenform" action="http://xxx/zfp"&gt;&lt;input type="hidden" name="wa" value="wsignin1.0" /><input type="hidden" name="wresult" value=...