Python Forum
# of bytes used to store a Unicode character - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: # of bytes used to store a Unicode character (/thread-15493.html)



# of bytes used to store a Unicode character - insearchofanswers87 - Jan-19-2019

I read somewhere that Python 3 uses 2 or 4 byte Unicode characters depending on how the particular implementation was built.

1. Does Python 3 always use 2 or 4 bytes by default?

2. How can I check my system to determine which size is actually being used?

Thanks.


RE: # of bytes used to store a Unicode character - ichabod801 - Jan-19-2019

By default, Python 3.0+ uses UTF-8. UTF-8 does not have a consistent character width. Details on the default are here.


RE: # of bytes used to store a Unicode character - insearchofanswers87 - Jan-19-2019

do you happen to know whether any python implementations default to an encoding other than UTF-8?


RE: # of bytes used to store a Unicode character - ichabod801 - Jan-19-2019

I have no idea.