Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Handling Unicode Data in Amazon S3 Headers
# During a recent project, I ran into an issue when handling Unicode data in metadata headers in Amazon S3.
# Apparently, Amazon adds on "?UTF-8?B?" in front of any Unicode data and "?=" in end of the data.
# I could not find any existing standard that describes this or why it is done, but I surmise this probably
# has to do with Base-64 encoding and how it handles Unicode.
#
# As per @rawnsley:
# apparently this is because HTTP headers must only be encoded in ASCII: http://stackoverflow.com/a/4410331/671393
#
# An easy Perl hack to get around this is as following (assuming you are using MIME::Base64 module):
if($var =~ m/^=?UTF-8?B?(.*)?=/) {
$results = decode_base64($var);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.