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
1502
votes
16 answers

When are you supposed to use escape instead of encodeURI / encodeURIComponent?

When encoding a query string to be sent to a web server - when do you use escape() and when do you use encodeURI() or encodeURIComponent(): Use escape: escape("% +&="); OR use encodeURI() /…
Adam
  • 28,537
  • 15
  • 60
  • 73
1209
votes
8 answers

How can I do Base64 encoding in Node.js?

Does Node.js have built-in Base64 encoding yet? The reason why I ask this is that final() from crypto can only output hexadecimal, binary or ASCII data. For example: var cipher = crypto.createCipheriv('des-ede3-cbc', encryption_key, iv); var ciph =…
murvinlai
  • 48,919
  • 52
  • 129
  • 177
1013
votes
19 answers

What is base 64 encoding used for?

I've heard people talking about "base 64 encoding" here and there. What is it used for?
MrDatabase
  • 43,245
  • 41
  • 111
  • 153
932
votes
20 answers

Converting string to byte array in C#

I'm converting something from VB into C#. Having a problem with the syntax of this statement: if ((searchResult.Properties["user"].Count > 0)) { profile.User = System.Text.Encoding.UTF8.GetString(searchResult.Properties["user"][0]); } I then…
nouptime
  • 9,929
  • 5
  • 22
  • 37
823
votes
11 answers

Java URL encoding of query string parameters

Say I have a URL http://example.com/query?q= and I have a query entered by the user such as: random word £500 bank $ I want the result to be a properly encoded URL: http://example.com/query?q=random%20word%20%A3500%20bank%20%24 What's the best…
user1277546
  • 8,652
  • 3
  • 17
  • 25
791
votes
11 answers

What is the best collation to use for MySQL with PHP?

Is there a collation type which is officially recommended by MySQL, for a general website where you aren't 100% sure of what will be entered? I understand that all the encodings should be the same, such as MySQL, Apache, the HTML and anything inside…
Darryl Hein
  • 142,451
  • 95
  • 218
  • 261
724
votes
18 answers

What is the difference between UTF-8 and Unicode?

I have heard conflicting opinions from people - according to the Wikipedia UTF-8 page. They are the same thing, aren't they? Can someone clarify?
sarsnake
  • 26,667
  • 58
  • 180
  • 286
644
votes
36 answers

Excel to CSV with UTF8 encoding

I have an Excel file that has some Spanish characters (tildes, etc.) that I need to convert to a CSV file to use as an import file. However, when I do Save As CSV it mangles the "special" Spanish characters that aren't ASCII characters. It also…
Jeff Treuting
  • 13,910
  • 8
  • 36
  • 47
506
votes
5 answers

What is the difference between utf8mb4 and utf8 charsets in MySQL?

What is the difference between utf8mb4 and utf8 charsets in MySQL? I already know about ASCII, UTF-8, UTF-16 and UTF-32 encodings; but I'm curious to know whats the difference of utf8mb4 group of encodings with other encoding types defined in MySQL…
Mojtaba Rezaeian
  • 8,268
  • 8
  • 31
  • 54
505
votes
7 answers

How to configure encoding in Maven?

When I run maven install on my multi module maven project I always get the following output: [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! So, I googled around a bit, but all I can find…
Ethan Leroy
  • 15,804
  • 9
  • 41
  • 63
483
votes
9 answers

What are Unicode, UTF-8, and UTF-16?

What's the basis for Unicode and why the need for UTF-8 or UTF-16? I have researched this on Google and searched here as well, but it's not clear to me. In VSS, when doing a file comparison, sometimes there is a message saying the two files have…
SoftwareGeek
  • 15,234
  • 19
  • 61
  • 78
473
votes
10 answers

Why does a base64 encoded string have an = sign at the end

I know what base64 encoding is and how to calculate base64 encoding in C#, however I have seen several times that when I convert a string into base64, there is an = at the end. A few questions came up: Does a base64 string always end with =? Why…
santosh singh
  • 27,666
  • 26
  • 83
  • 129
460
votes
2 answers

Working with UTF-8 encoding in Python source

Consider: $ cat bla.py u = unicode('d…') s = u.encode('utf-8') print s $ python bla.py File "bla.py", line 1 SyntaxError: Non-ASCII character '\xe2' in file bla.py on line 1, but no encoding declared; see http://www.python.org/peps/pep-0263.html…
Nullpoet
  • 10,949
  • 20
  • 48
  • 65
418
votes
19 answers

How can I find encoding of a file via a script on Linux?

I need to find the encoding of all files that are placed in a directory. Is there a way to find the encoding used? The file command is not able to do this. The encoding of interest to me is ISO 8859-1. If the encoding is anything else, I want to…
Manglu
  • 10,744
  • 12
  • 44
  • 57
405
votes
6 answers

How can I percent-encode URL parameters in Python?

If I do url = "http://example.com?p=" + urllib.quote(query) It doesn't encode / to %2F (breaks OAuth normalization) It doesn't handle Unicode (it throws an exception) Is there a better library?
Paul Tarjan
  • 48,968
  • 59
  • 172
  • 213
1
2 3
99 100