Last active
January 17, 2016 16:00
-
-
Save yakovsh/f7f2c5fbc7ef93fefe22 to your computer and use it in GitHub Desktop.
Handling Unicode Data in Amazon S3 Headers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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