Encoding Problems When Running an App in Docker (Python, Java, Ruby, ...) with Ubuntu Containers (Ascii, Utf-8)

Encoding Problems when running an app in docker (Python, Java, Ruby, ...) with Ubuntu Containers (ascii, utf-8)

You need to set the locale correct.

This is the minimal correct Dockerfile:

FROM ubuntu

RUN apt update && apt -y install locales && locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

The usual docker images don't specify a locales. You see it if you bash into it and execute locale:

sudo docker exec -i -t yowsup3 bash

Sources:

  • http://jaredmarkell.com/docker-and-locales/
  • https://github.com/docker-library/python/issues/13

UTF-8 encoding not working in Docker

You can check by using below command to set java parameters and then try to run your java program -

export JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8

If it worked using above command, set it using an ENV command during docker image build.

Also if you need to set it in bash_profile, refer below portion of Dockerfile -

RUN echo "JAVA_HOME=/opt/jdk1.8.0_65" >> ~/.bash_profile

UTF-8 In Python logging, how?

Check that you have the latest Python 2.6 - some Unicode bugs were found and fixed since 2.6 came out. For example, on my Ubuntu Jaunty system, I ran your script copied and pasted, removing only the '/home/ted/' prefix from the log file name. Result (copied and pasted from a terminal window):


vinay@eta-jaunty:~/projects/scratch$ python --version
Python 2.6.2
vinay@eta-jaunty:~/projects/scratch$ python utest.py
printed unicode object: ô
vinay@eta-jaunty:~/projects/scratch$ cat logfile.txt
ô
vinay@eta-jaunty:~/projects/scratch$

On a Windows box:


C:\temp>python --version
Python 2.6.2

C:\temp>python utest.py
printed unicode object: ô

And the contents of the file:

alt text

This might also explain why Lennart Regebro couldn't reproduce it either.

Jenkins file encoding for npm

I found out that one of the Jenkins Slave servers was had its encoding set to ISO-8859-1 instead of UTF8. Even though the Master server was set to UTF8 and the job itself was setting the LOCALE to UTF8 it was being overridden by the Slave configuration.

How can I run a Microsoft Virtual PC image of XP with IE6 on XP?

You misunderstand how Virtual PC works. You can create a VMC file by creating a new Virtual PC then choosing to use an existing VHD rather than create a new one. There is nothing specific about VHDs that limit them to the new Win7 virtualization package.

Whilst I agree the VirtualPC for XP/Vista download is now relegated to the MS download site there's nothing stopping you using the IE6 virtual hard drives at all and indeed the instructions on how to use it are on the download page itself.



Related Topics



Leave a reply



Submit