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
60
votes
2 answers

Python 2.7 : LookupError: unknown encoding: cp65001

I have installed python 2(64 bit), on windows 8.1 (64 bit) and wanted to know pip version and for that I fired pip --version but it is giving error. C:\Users\ADMIN>pip --version Traceback (most recent call last): File…
Himanshu Bhandari
  • 1,769
  • 2
  • 23
  • 37
60
votes
1 answer

How to see the file's encoding in emacs?

I don't find the encoding of current file, how to display it? You can see there are some Chinese characters in the file, but I don't know what the encoding it is. Is there any way to let it always show on the emacs GUI?
Freewind
  • 193,756
  • 157
  • 432
  • 708
59
votes
4 answers

write utf-8 characters to file with fputcsv in php

I want to try write Persian character in CSV file in PHP, I am using fputcsv function but how can write UTF-8 character to CSV file with fputcsv? Part of my code: $df = fopen($filepath, 'w'); fputcsv($df, array($coupon->code, $discount->label));
Yuseferi
  • 7,931
  • 11
  • 67
  • 103
58
votes
9 answers

How to encode periods for URLs in Javascript?

The SO post below is comprehensive, but all three methods described fail to encode for periods. Post: Encode URL in JavaScript? For instance, if I run the three methods (i.e., escape, encodeURI, encodeURIComponent), none of them encode periods. So…
Crashalot
  • 33,605
  • 61
  • 269
  • 439
58
votes
2 answers

Is there any benefit to adding accept-charset="UTF-8" to HTML forms, if the page is already in UTF-8?

For pages already specified (either by HTTP header, or by meta tag), to have a Content-Type with a UTF-8 charset... is there a benefit of adding accept-charset="UTF-8" to HTML forms? (I understand the accept-charset attribute is broken in IE for…
philfreo
  • 41,941
  • 26
  • 128
  • 141
57
votes
1 answer

Signing and verifying signatures with RSA C#

I recently posted about issues with encrypting large data with RSA, I am finally done with that and now I am moving on to implementing signing with a user's private key and verifying with the corresponding public key. However, whenever I compare the…
Simon Langhoff
  • 1,395
  • 3
  • 18
  • 28
57
votes
3 answers

Email from PHP has broken Subject header encoding

My PHP script sends email to users and when the email arrives to their mailboxes, the subject line ($subject) has characters like a^£ added to the end of my subject text. This is obviously and encoding problem. The email message content itself is…
daza166
  • 3,543
  • 10
  • 35
  • 41
57
votes
5 answers

How do I write out a text file in C# with a code page other than UTF-8?

I want to write out a text file. Instead of the default UTF-8, I want to write it encoded as ISO-8859-1 which is code page 28591. I have no idea how to do this... I'm writing out my file with the following very simple code: using (StreamWriter sw =…
adeena
  • 4,027
  • 15
  • 40
  • 52
57
votes
6 answers

How to detect string byte encoding?

I've got about 1000 filenames read by os.listdir(), some of them are encoded in UTF8 and some are CP1252. I want to decode all of them to Unicode for further processing in my script. Is there a way to get the source encoding to correctly decode into…
Philipp
  • 1,001
  • 3
  • 10
  • 10
56
votes
10 answers

How can I write a file in UTF-8 format?

I have bunch of files that are not in UTF-8 encoding and I'm converting a site to UTF-8 encoding. I'm using simple script for files that I want to save in UTF-8, but the files are saved in old encoding: header('Content-type: text/html;…
Starmaster
  • 842
  • 1
  • 6
  • 9
56
votes
7 answers

How to determine encoding table of a text file

I have .txt and .java files and I don't know how to determine the encoding table of the files (Unicode, UTF-8, ISO-8525, …). Does there exist any program to determine the file encoding or to see the encoding?
Ballon
  • 6,882
  • 18
  • 49
  • 63
56
votes
8 answers

encoding UTF8 does not match locale en_US; the chosen LC_CTYPE setting requires encoding LATIN1

While trying to install opennms : /usr/share/opennms/bin/install -l /usr/local/lib -dis I get the error: ERROR: encoding UTF8 does not match locale en_US Detail: The chosen LC_CTYPE setting requires encoding LATIN1. and I'm not sure how to…
kamal
  • 9,637
  • 30
  • 101
  • 168
56
votes
2 answers

DELETE using CURL with encoded URL

I’m trying to make a request using CURL like this: curl -X DELETE "https://myhost/context/path/users/OXYugGKg207g5uN/07V" where OXYugGKg207g5uN/07V is a hash, so I suppose that I need to encode before do this request. I have tried curl -X DELETE…
coffee
  • 3,048
  • 4
  • 32
  • 46
56
votes
5 answers

How to print UTF-8 encoded text to the console in Python < 3?

I'm running a recent Linux system where all my locales are UTF-8: LANG=de_DE.UTF-8 LANGUAGE= LC_CTYPE="de_DE.UTF-8" LC_NUMERIC="de_DE.UTF-8" LC_TIME="de_DE.UTF-8" ... LC_IDENTIFICATION="de_DE.UTF-8" LC_ALL= Now I want to write UTF-8 encoded content…
Brutus
  • 7,139
  • 7
  • 36
  • 41
55
votes
7 answers

What is the Java's internal represention for String? Modified UTF-8? UTF-16?

I searched Java's internal representation for String, but I've got two materials which look reliable but inconsistent. One is: http://www.codeguru.com/cpp/misc/misc/multi-lingualsupport/article.php/c10451 and it says: Java uses UTF-16 for the…
Johnny Lim
  • 5,623
  • 8
  • 38
  • 53