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
104
votes
5 answers

What is the equivalent of JavaScript's encodeURIcomponent in PHP?

What is the equivalent of JavaScript's encodeURIcomponent function in PHP?
Gal
  • 23,122
  • 32
  • 97
  • 118
100
votes
16 answers

java.lang.IllegalArgumentException: Malformed \uxxxx encoding while mvn install

While running mvn install in my project, I end up with this error. While a lot of answers and resources point out errors in / vs \, I want to mention that I have no local changes and this repo just works fine for others in my team. It worked fine…
Shylajhaa
  • 1,418
  • 2
  • 11
  • 20
100
votes
23 answers

How to convert a string with Unicode encoding to a string of letters

I have a string with escaped Unicode characters, \uXXXX, and I want to convert it to regular Unicode letters. For example: "\u0048\u0065\u006C\u006C\u006F World" should become "Hello World" I know that when I print the first string it already…
SharonBL
  • 1,735
  • 5
  • 20
  • 28
98
votes
4 answers

What's the difference between UTF8/UTF16 and Base64 in terms of encoding

In. c# We can use below classes to do encoding: System.Text.Encoding.UTF8 System.Text.Encoding.UTF16 System.Text.Encoding.ASCII Why there is no System.Text.Encoding.Base64? We can only use Convert.From(To)Base64String method, what's special of…
Zhongmin
  • 1,684
  • 1
  • 16
  • 33
98
votes
6 answers

How to Find the Default Charset/Encoding in Java?

The obvious answer is to use Charset.defaultCharset() but we recently found out that this might not be the right answer. I was told that the result is different from real default charset used by java.io classes in several occasions. Looks like Java…
ZZ Coder
  • 74,484
  • 29
  • 137
  • 169
96
votes
5 answers

Difference between Url Encode and HTML encode

What’s the difference between an URL Encode and a HTML Encode?
Quintin Par
  • 15,862
  • 27
  • 93
  • 146
92
votes
13 answers

How can I send and receive WebSocket messages on the server side?

How can I send and receive messages on the server side using WebSocket, as per the protocol? Why do I get seemingly random bytes at the server when I send data from the browser to the server? It the data encoded somehow? How does the framing work…
pimvdb
  • 151,816
  • 78
  • 307
  • 352
92
votes
9 answers

How to encode text to base64 in python

I am trying to encode a text string to base64. i tried doing this : name = "your name" print('encoding %s in base64 yields = %s\n'%(name,name.encode('base64','strict'))) But this gives me the following error: LookupError: 'base64' is not a text…
sukhvir
  • 5,265
  • 6
  • 41
  • 43
92
votes
6 answers

Unicode via CSS :before

I am using Font Awesome on my webpage and I want to display an icon inside the :before pseudo element. According to the documentation/cheatsheet, I have to type  to get this font, but it isn't working. I believe that is normal because HTML…
Sven
  • 12,997
  • 27
  • 90
  • 148
91
votes
21 answers

PHP output showing little black diamonds with a question mark

I'm writing a php program that pulls from a database source. Some of the varchars have quotes that are displaying as black diamonds with a question mark in them (�, REPLACEMENT CHARACTER, I assume from Microsoft Word text). How can I use php to…
Steve Zajaczkowski
90
votes
4 answers

How many characters are there in a GUID?

Using ASCII encoding, how many characters are there in a GUID? I'm interested in the Microsoft style, which includes the curly brackets and dashes.
Jim Counts
  • 12,535
  • 9
  • 45
  • 63
90
votes
9 answers

Reading UTF-8 - BOM marker

I'm reading a file through a FileReader - the file is UTF-8 decoded (with BOM) now my problem is: I read the file and output a string, but sadly the BOM marker is outputted too. Why this occurs? fr = new FileReader(file); br = new…
onigunn
  • 4,730
  • 10
  • 58
  • 89
89
votes
3 answers

fileReader.readAsBinaryString to upload files

Trying to use fileReader.readAsBinaryString to upload a PNG file to the server via AJAX, stripped down code (fileObject is the object containing info on my file); var fileReader = new FileReader(); fileReader.onload = function(e) { var…
Blank
  • 4,635
  • 5
  • 33
  • 53
89
votes
8 answers

Why is base128 not used?

Why is only base64 instead of base128 used to transmit binary data on the web? The ASCII character set has 128 characters which in theory could represent base 128, but only base64 but not base128 is used in most cases.
gmadar
  • 1,884
  • 3
  • 19
  • 22
88
votes
2 answers

Is '# -*- coding: utf-8 -*-' also a comment in Python?

As we use # for inserting comments in Python, then how does Python treat: # -*- coding: utf-8 -*- differently?
ngShravil.py
  • 4,742
  • 3
  • 18
  • 30