Skip to content

Instantly share code, notes, and snippets.

@yakovsh
Last active January 17, 2016 16:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yakovsh/f7f2c5fbc7ef93fefe22 to your computer and use it in GitHub Desktop.
Save yakovsh/f7f2c5fbc7ef93fefe22 to your computer and use it in GitHub Desktop.
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