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
64
votes
3 answers

How do I avoid character encoding when using "FOR XML PATH"?

I'm looking to create a comma-separated list of values from a SQL Server 2005 table, just like in JanetOhara's question. I'm using a query similar to the one presented in techdo's answer to the question. Everything is working, except the list of…
dangowans
  • 2,263
  • 3
  • 25
  • 40
63
votes
10 answers

Windows cmd encoding change causes Python crash

First I change Windows CMD encoding to utf-8 and run Python interpreter: chcp 65001 python Then I try to print a unicode sting inside it and when i do this Python crashes in a peculiar way (I just get a cmd prompt in the same window). >>> import…
Alex
  • 43,191
  • 44
  • 96
  • 127
63
votes
7 answers

Why is base64_encode() adding a slash "/" in the result?

I am encoding the URL suffix of my application: $url = 'subjects?_d=1'; echo base64_encode($url); // Outputs c3ViamVjdHM/X2Q9MQ== Notice the slash before 'X2'. Why is this happening? I thought base64 only outputted A-Z, 0-9 and '=' as padding?
BadHorsie
  • 14,135
  • 30
  • 117
  • 191
62
votes
7 answers

Python JSON encoding

I'm trying to encode data to JSON in Python and I been having a quite a bit of trouble. I believe the problem is simply a misunderstanding. I'm relatively new to Python and never really got familiar with the various Python data types, so that's…
KeyboardInterrupt
  • 3,483
  • 8
  • 36
  • 41
62
votes
3 answers

how to change source file encoding in csharp project (visual studio / msbuild machine)?

Is there a way to force VS to use Unicode always, instead of weird ISO-something? I'm working on a winapp csproject using Visual Studio 2008 on Vista (Polish locale). The problem appears when I build the project on Win Server 2003 (English locale) -…
tomo
  • 1,942
  • 2
  • 29
  • 43
62
votes
5 answers

Encode/Decode Array of Types conforming to protocol with JSONEncoder

I'm trying to find the best way to Encode/Decode an array of structs conforming to a swift protocol using the new JSONDecoder/Encoder in Swift 4. I made up a little example to illustrate the problem: First we have a protocol Tag and some Types that…
goesta
  • 649
  • 1
  • 6
  • 13
62
votes
2 answers

Decode gzipped web page retrieved via cURL in PHP

I'm retrieving a gzipped web page via curl, but when I output the retrieved content to the browser I just get the raw gzipped data. How can I decode the data in PHP? One method I found was to write the content to a tmp file and then ... $f =…
Ian
  • 11,920
  • 27
  • 61
  • 77
62
votes
3 answers

Byte and char conversion in Java

If I convert a character to byte and then back to char, that character mysteriously disappears and becomes something else. How is this possible? This is the code: char a = 'È'; // line 1 byte b = (byte)a; // line 2 char c =…
user1883212
  • 7,539
  • 11
  • 46
  • 82
62
votes
6 answers

Batch file encoding

I would like to deal with filename containing strange characters, like the French é. Everything is working fine in the shell: C:\somedir\>ren -hélice hélice I know if I put this line in a .bat file, I obtain the following result: C:\somedir\>ren…
shodanex
  • 14,975
  • 11
  • 57
  • 91
62
votes
11 answers

How do I correct the character encoding of a file?

I have an ANSI encoded text file that should not have been encoded as ANSI as there were accented characters that ANSI does not support. I would rather work with UTF-8. Can the data be decoded correctly or is it lost in transcoding? What tools could…
Liam
  • 19,819
  • 24
  • 83
  • 123
61
votes
5 answers

Change the default encoding for saving files with Notepad++

That's it . I want to open all the files in once (to make replacements). But notepad++ opens them all in ANSI and I have to go through each file and change the encoding to UTF-8.
Abdelwahed
  • 1,694
  • 4
  • 21
  • 31
61
votes
7 answers

How to source() .R file saved using UTF-8 encoding?

The following, when copied and pasted directly into R works fine: > character_test <- function() print("R同时也被称为GNU S是一个强烈的功能性语言和环境,探索统计数据集,使许多从自定义数据图形显示...") > character_test() [1] "R同时也被称为GNU S是一个强烈的功能性语言和环境,探索统计数据集,使许多从自定义数据图形显示..." However, if I…
Tony Breyal
  • 5,338
  • 3
  • 29
  • 49
61
votes
5 answers

How to make python 3 print() utf8

How can I make python 3 (3.1) print("Some text") to stdout in UTF-8, or how to output raw bytes? Test.py TestText = "Test - āĀēĒčČ..šŠūŪžŽ" # this is UTF-8 TestText2 = b"Test2 -…
davispuh
  • 1,419
  • 3
  • 18
  • 30
61
votes
11 answers

Setting the character encoding in form submit for Internet Explorer

I have a page that contains a form. This page is served with content type text/html;charset=utf-8. I need to submit this form to server using ISO-8859-1 character encoding. Is this possible with Internet Explorer? Setting accept-charset attribute to…
Juha Syrjälä
  • 33,425
  • 31
  • 131
  • 183
60
votes
4 answers

How to encode a query string so that it is the value of another query string in javascript?

I have a javascript function which passes as a query string value another query string. In other words, I want the query string to be: http://www.somesite.com/?somequery=%3fkey%3dvalue1%2520%26%2520key2%3value3 However, if I redirect like…
rmw
  • 1,253
  • 1
  • 12
  • 20