Questions tagged [encoding]

Encoding is a set of predefined rules to reversibly transform a piece of information in a certain representation into a completely different representation. The other way round is called decoding. This tag is rather generic, but it is mainly used for binary encoding schemes such as base 64 and hexadecimal.

There are a lot of different applications:

  • which is how the computer represents characters like a and , which humans can recognize, into bytes, which computers can recognize.
  • which is used to transform between videos and bytes.
  • which is used to transform between plain text and valid URIs. Also known as .
  • which is used to transform between plain text and valid XML.
  • which is used to compress/decompress bytes.
24174 questions
74
votes
11 answers

Java - Convert String to valid URI object

I am trying to get a java.net.URI object from a String. The string has some characters which will need to be replaced by their percentage escape sequences. But when I use URLEncoder to encode the String with UTF-8 encoding, even the / are replaced…
lostInTransit
  • 70,519
  • 61
  • 198
  • 274
74
votes
3 answers

Is there a standard way to encode a .NET string into JavaScript string for use in MS Ajax?

I'm trying to pass the output of a SQL Server exception to the client using the RegisterStartUpScript method of the MS ScriptManager in .NET 3.5. This works fine for some errors but when the exception contains single quotes the alert fails. I dont…
Rich Andrews
  • 4,168
  • 3
  • 35
  • 48
74
votes
14 answers

How to convert hex to ASCII characters in the Linux shell?

Let's say that I have a string 5a. This is the hex representation of the ASCII letter Z. I need to find a Linux shell command which will take a hex string and output the ASCII characters that the hex string represents. So if I do: echo 5a |…
Krystian Cybulski
  • 10,789
  • 12
  • 67
  • 98
74
votes
6 answers

How to replace Microsoft-encoded quotes in PHP

I need to replace Microsoft Word's version of single and double quotations marks (“ ” ‘ ’) with regular quotes (' and ") due to an encoding issue in my application. I do not need them to be HTML entities and I cannot change my database schema. I…
Misha M
  • 10,979
  • 17
  • 53
  • 65
73
votes
11 answers

How to convert \uXXXX unicode to UTF-8 using console tools in *nix

I use curl to get some URL response, it's JSON response and it contains unicode-escaped national characters like \u0144 (ń) and \u00f3 (ó). How can I convert them to UTF-8 or any other encoding to save into file?
Krzysztof Wolny
  • 10,576
  • 4
  • 34
  • 46
72
votes
13 answers

Best way to encode text data for XML

I was looking for a generic method in .Net to encode a string for use in an Xml element or attribute, and was surprised when I didn't immediately find one. So, before I go too much further, could I just be missing the built-in function? Assuming…
Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
72
votes
3 answers

How to read an ANSI encoded file containing special characters

I'm writing a TFS Checkin policy, which checks if our source files containing our file header. My problem is, that our file header contains a special character "©" and unfortunately some of our source files are encoded in ANSI. So if I read these…
Enyra
  • 17,542
  • 12
  • 35
  • 44
71
votes
4 answers

Which encoding uses the \x (backslash x) prefix?

I'm attempting to decode text which is prefixing certain 'special characters' with \x. I've worked out the following mappings by hand: \x28 ( \x29 ) \x3a : e.g. 12\x3a39\x3a03 AM Does anyone recognise what this encoding is?
Alex Angas
  • 59,219
  • 41
  • 137
  • 210
71
votes
2 answers

UnicodeEncodeError: 'ascii' codec can't encode character at special name

My python (ver 2.7) script is running well to get some company name from local html files but when it comes to some specific country name, it gives this error "UnicodeEncodeError: 'ascii' codec can't encode character" Specially getting error when…
rhb1
  • 753
  • 1
  • 7
  • 8
71
votes
11 answers

Error: "Input is not proper UTF-8, indicate encoding !" using PHP's simplexml_load_string

I'm getting the error: parser error : Input is not proper UTF-8, indicate encoding ! Bytes: 0xED 0x6E 0x2C 0x20 When trying to process an XML response using simplexml_load_string from a 3rd party source. The raw XML response does declare the content…
Camsoft
  • 11,718
  • 19
  • 83
  • 120
71
votes
7 answers

What is the default encoding of the JVM?

Is UTF-8 the default encoding in Java? If not, how can I know which encoding is used by default?
user67722
  • 3,217
  • 5
  • 24
  • 20
70
votes
25 answers

Listings in Latex with UTF-8 (or at least german umlauts)

Trying to include a source-file into my latex document using the listings package, i got problems with german umlauts inside of the comments in the code. Using \lstset{ extendedchars=\true, inputencoding=utf8x } Umlauts in the source files (encoded…
Janosch
  • 1,204
  • 1
  • 11
  • 19
69
votes
6 answers

Why do real-world servers prefer gzip over deflate encoding?

We already know deflate encoding is a winner over gzip with respect to speed of encoding, decoding and compression size. So why do no large sites (that I can find) send it (when I use a browser that accepts it)? Yahoo claims deflate is "less…
Steve Clay
  • 8,671
  • 2
  • 42
  • 48
69
votes
11 answers

What charset does Microsoft Excel use when saving files?

I have a Java app which reads CSV files which have been created in Excel (e.g. 2007). Does anyone know what charset MS Excel uses to save these files in? I would have guessed either: windows-1255 (Cp1255) ISO-8859-1 UTF8 but I am unable to decode…
Joel
  • 29,538
  • 35
  • 110
  • 138
68
votes
2 answers

URL-encoded form data is not valid

I have a webpage that posts multiple form tags. It's an inline edit page, where I can either post one row at a time or multiple rows. Last night, without making any changes to the code or data, I started getting The URL-encoded form data is not…
Paul Kogan
  • 681
  • 1
  • 5
  • 3