Questions tagged [decode]

To convert some encoded data (e.g. bytes, electrical signals) to some representation ready for further processing (e.g. string, object, picture)

4353 questions
1003
votes
14 answers

UnicodeDecodeError: 'charmap' codec can't decode byte X in position Y: character maps to

I'm trying to get a Python 3 program to do some manipulations with a text file filled with information. However, when trying to read the file I get the following error: Traceback (most recent call last): File "SCRIPT LOCATION", line NUMBER, in…
Eden Crow
  • 14,684
  • 11
  • 26
  • 24
465
votes
13 answers

UnicodeDecodeError, invalid continuation byte

Why is the below item failing? Why does it succeed with "latin-1" codec? o = "a test of \xe9 char" #I want this to remain a string as this is what I am receiving v = o.decode("utf-8") Which results in: Traceback (most recent call last): File…
RuiDC
  • 8,403
  • 7
  • 26
  • 21
378
votes
19 answers

Encoding as Base64 in Java

I need to encode some data in the Base64 encoding in Java. How do I do that? What is the name of the class that provides a Base64 encoder? I tried to use the sun.misc.BASE64Encoder class, without success. I have the following line of Java 7…
Jury A
  • 19,192
  • 24
  • 69
  • 93
335
votes
10 answers

How do you decode Base64 data in Python?

I have the following piece of Base64 encoded data, and I want to use the Python Base64 module to extract information from it. It seems that module does not work. How can I make it…
ladyfafa
  • 6,629
  • 7
  • 26
  • 22
232
votes
0 answers

Decode & back to & in JavaScript

I have strings like var str = 'One & two & three'; rendered into HTML by the web server. I need to transform those strings into 'One & two & three' Currently, that's what I am doing (with help of…
Art
  • 23,747
  • 29
  • 89
  • 101
188
votes
6 answers

UnicodeEncodeError: 'charmap' codec can't encode - character maps to , print function

I am writing a Python (Python 3.3) program to send some data to a webpage using POST method. Mostly for debugging process I am getting the page result and displaying it on the screen using print() function. The code is like…
187
votes
6 answers

Base64 Java encode and decode a string

I want to encode a string into base64 and transfer it through a socket and decode it back. But after decoding it gives different answer. Following is my code and result is "77+9x6s=" import javax.xml.bind.DatatypeConverter; public class f{ …
Sameera Kumarasingha
  • 2,908
  • 3
  • 25
  • 41
186
votes
12 answers

How can I unescape HTML character entities in Java?

Basically, I would like to decode a given HTML document, and replace all special characters, such as " " → " " and ">" → ">". In .NET, we can make use of the HttpUtility.HtmlDecode method. What's the equivalent function in Java?
yinyueyouge
  • 3,684
  • 4
  • 25
  • 22
124
votes
5 answers

Code for decoding/encoding a modified base64 URL (in ASP.NET Framework)

I want to base64 encode data to put it in a URL and then decode it within my HttpHandler. I have found that Base64 Encoding allows for a '/' character which will mess up my UriTemplate matching. Then I found that there is a concept of a "modified…
Kirk Liemohn
  • 7,733
  • 9
  • 46
  • 57
119
votes
7 answers

How do I decode a string with escaped unicode?

I'm not sure what this is called so I'm having trouble searching for it. How can I decode a string with unicode from http\u00253A\u00252F\u00252Fexample.com to http://example.com with JavaScript? I tried unescape, decodeURI, and decodeURIComponent…
styfle
  • 22,361
  • 27
  • 86
  • 128
114
votes
9 answers

How to decode a QR-code image in (preferably pure) Python?

TL;DR: I need a way to decode a QR-code from an image file using (preferable pure) Python. I've got a jpg file with a QR-code which I want to decode using Python. I've found a couple libraries which claim to do this: PyQRCode (website here) which…
kramer65
  • 50,427
  • 120
  • 308
  • 488
112
votes
6 answers

AJAX POST and Plus Sign ( + ) -- How to Encode?

I'm POSTing the contents of a form field via AJAX to a PHP script and using JavaScript to escape(field_contents). The problem is that any plus signs are being stripped out and replaced by spaces. How can I safely 'encode' the plus sign and then…
jalperin
  • 2,664
  • 9
  • 30
  • 32
102
votes
6 answers

How to decode the JWT encoded token payload on client-side in angular?

I am getting one JWT encoded access token from my API in response. But I am not able to decode it and get it in JSON format. I tried using the angular2-jwt library for it, but it did not worked. I am writing my code below: …
Sunny Parekh
  • 1,049
  • 2
  • 7
  • 8
90
votes
7 answers

Decoding facebook's blob video url

I found blob:https://www.facebook.com/c7e5a634-2343-4464-a03e-4a1987301ca1 video source on Facebook's private group and I really can't download the video by entering the url nor am I able to decode. Is there any way to decode this?
ujwal dhakal
  • 2,289
  • 2
  • 30
  • 50
81
votes
6 answers

How to fix ''UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 29815: character maps to ''?

At the moment, I am trying to get a Python 3 program to do some manipulations with a text file filled with information, through the Spyder IDE/GUI. However, when trying to read the file I get the following error: File…
user3443027
  • 951
  • 1
  • 7
  • 9
1
2 3
99 100