Python Unicode Encode Error

Likely, your problem is that you parsed it okay, and now you’re trying to print the contents of the XML and you can’t because theres some foreign Unicode characters. Try to encode your unicode string as ascii first: unicodeData.encode(‘ascii’, ‘ignore’) the ‘ignore’ part will tell it to just skip those characters. From the python docs: … Read more

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

Also check class HttpServerUtility with UrlTokenEncode and UrlTokenDecode methods that is handling URL safe Base64 encoding and decoding. Note 1: The result is not a valid Base64 string. Some unsafe characters for URL are replaced. Note 2: The result differs from the base64url algorithm in RFC4648, it replaces the ‘=’ padding with ‘0’, ‘1’ or … Read more

UnicodeEncodeError: ‘charmap’ codec can’t encode – character maps to , print function [duplicate]

I see three solutions to this: Change the output encoding, so it will always output UTF-8. See e.g. Setting the correct encoding when piping stdout in Python, but I could not get these example to work. Following example code makes the output aware of your target charset. # -*- coding: utf-8 -*- import sys print … Read more

Encoding as Base64 in Java

You need to change the import of your class: import org.apache.commons.codec.binary.Base64; And then change your class to use the Base64 class. Here’s some example code: byte[] encodedBytes = Base64.encodeBase64(“Test”.getBytes()); System.out.println(“encodedBytes ” + new String(encodedBytes)); byte[] decodedBytes = Base64.decodeBase64(encodedBytes); System.out.println(“decodedBytes ” + new String(decodedBytes)); Then read why you shouldn’t use sun.* packages. Update (2016-12-16) You can … Read more