Clarify b64encode with Python 2 (#67488)

This commit is contained in:
Jordan Borean 2020-02-18 05:31:03 +10:00 committed by GitHub
parent 36ed3321fd
commit 423a900791
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1512,12 +1512,15 @@ To concatenate a list into a string::
To work with Base64 encoded strings::
{{ encoded | b64decode }}
{{ decoded | b64encode }}
{{ decoded | string | b64encode }}
As of version 2.6, you can define the type of encoding to use, the default is ``utf-8``::
{{ encoded | b64decode(encoding='utf-16-le') }}
{{ decoded | b64encode(encoding='utf-16-le') }}
{{ decoded | string | b64encode(encoding='utf-16-le') }}
.. note:: The ``string`` filter is only required for Python 2 and ensures that text to encode is a unicode string.
Without that filter before b64encode the wrong value will be encoded.
.. versionadded:: 2.6