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

Url decode UTF-8 in Python

In Python 2.7, given a URL like example.com?title=%D0%BF%D1%80%D0%B0%D0%B2%D0%BE%D0%B2%D0%B0%D1%8F+%D0%B7%D0%B0%D1%89%D0%B8%D1%82%D0%B0, how can I decode it to the expected result, example.com?title==правовая+защита? I tried…
swordholder
  • 4,519
  • 3
  • 18
  • 14
384
votes
6 answers

How do I see the current encoding of a file in Sublime Text?

How do I see the current encoding of a file in Sublime Text? This seems like a pretty simple thing to do but searching has not yielded much. Any pointers would be appreciated!
arturomp
  • 28,790
  • 10
  • 43
  • 72
379
votes
1 answer

NodeJS: How to decode base64 encoded string back to binary?

I was implementing password hashing with salt, so I generated salt as binary, hashed the password, base64 encoded the password and salt then stored them into database. Now when I am checking password, I am supposed to decode the salt back into…
Xavier_Ex
  • 8,432
  • 11
  • 39
  • 55
375
votes
14 answers

How to get UTF-8 working in Java webapps?

I need to get UTF-8 working in my Java webapp (servlets + JSP, no framework used) to support äöå etc. for regular Finnish text and Cyrillic alphabets like ЦжФ for special cases. My setup is the following: Development environment: Windows…
kosoant
  • 11,619
  • 7
  • 31
  • 37
373
votes
12 answers

Setting the correct encoding when piping stdout in Python

When piping the output of a Python program, the Python interpreter gets confused about encoding and sets it to None. This means a program like this: # -*- coding: utf-8 -*- print u"åäö" will work fine when run normally, but fail…
Joakim Lundborg
  • 10,920
  • 6
  • 32
  • 39
364
votes
19 answers

Using PowerShell to write a file in UTF-8 without the BOM

Out-File seems to force the BOM when using UTF-8: $MyFile = Get-Content $MyPath $MyFile | Out-File -Encoding "UTF8" $MyPath How can I write a file in UTF-8 with no BOM using PowerShell? Update 2021 PowerShell has changed a bit since I wrote this…
sourcenouveau
  • 29,356
  • 35
  • 146
  • 243
346
votes
4 answers

How do I decode a base64 encoded string?

I am trying to "decode" this following Base64 string: OBFZDTcPCxlCKhdXCQ0kMQhKPh9uIgYIAQxALBtZAwUeOzcdcUEeW0dMO1kbPElWCV1ISFFKZ0kdWFlLAURPZhEFQVseXVtPOUUICVhMAzcfZ14AVEdIVVgfAUIBWVpOUlAeaUVMXFlKIy9rGUN0VF08Oz1POxFfTCcVFw1LMQNbBQYWAQ== This is what…
Rickard
  • 3,471
  • 2
  • 16
  • 5
340
votes
4 answers

How can I convert a hex string to a byte array?

Can we convert a hex string to a byte array using a built-in function in C# or do I have to make a custom method for this?
Blankman
  • 259,732
  • 324
  • 769
  • 1,199
331
votes
26 answers

Detect encoding and make everything UTF-8

I'm reading out lots of texts from various RSS feeds and inserting them into my database. Of course, there are several different character encodings used in the feeds, e.g. UTF-8 and ISO 8859-1. Unfortunately, there are sometimes problems with the…
caw
  • 30,999
  • 61
  • 181
  • 291
324
votes
7 answers

Android Replace "..." with ellipsis character

Since AVD tools 16 I'm getting this warning: Replace "..." with ellipsis character (..., …) ? in my strings.xml at this line Searching... How do I replace ...? Is it just literally …? Could someone…
Blundell
  • 75,855
  • 30
  • 208
  • 233
322
votes
12 answers

Replace non-ASCII characters with a single space

I need to replace all non-ASCII (\x00-\x7F) characters with a space. I'm surprised that this is not dead-easy in Python, unless I'm missing something. The following function simply removes all non-ASCII characters: def remove_non_ascii_1(text): …
dotancohen
  • 30,064
  • 36
  • 138
  • 197
318
votes
19 answers

ArrayBuffer to base64 encoded string

I need an efficient (read native) way to convert an ArrayBuffer to a base64 string which needs to be used on a multipart post.
zaheer
  • 3,221
  • 2
  • 16
  • 4
312
votes
14 answers

Get encoding of a file in Windows

This isn't really a programming question, is there a command line or Windows tool (Windows 7) to get the current encoding of a text file? Sure I can write a little C# app but I wanted to know if there is something already built in?
TheWebGuy
  • 11,429
  • 16
  • 52
  • 72
310
votes
21 answers

How can I detect the encoding/codepage of a text file?

In our application, we receive text files (.txt, .csv, etc.) from diverse sources. When reading, these files sometimes contain garbage, because the files where created in a different/unknown codepage. Is there a way to (automatically) detect the…
GvS
  • 52,015
  • 16
  • 101
  • 139
310
votes
12 answers

How do I check if a string is unicode or ascii?

What do I have to do in Python to figure out which encoding a string has?
TIMEX
  • 259,804
  • 351
  • 777
  • 1,080