Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix locale and string encoding #1

Merged
merged 2 commits into from
Jul 3, 2024
Merged

Fix locale and string encoding #1

merged 2 commits into from
Jul 3, 2024

Conversation

TonyCTHsu
Copy link
Contributor

@TonyCTHsu TonyCTHsu commented Jul 2, 2024

Why

Discovered that the string encoding is US-ASCII

root@0f792b26260a:/# irb
irb(main):001:0> "".encoding
=> #<Encoding:US-ASCII>

Locale was not set correctly:

root@0f792b26260a:/# locale -a
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_COLLATE to default locale: No such file or directory
C
C.utf8
POSIX
root@0f792b26260a:/# locale
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

How

Before in the build process:

RUN locale-gen en_US.UTF-8
Generating locales (this might take a while)...
Generation complete.

How success looks like after the change

RUN locale-gen en_US.UTF-8
Generating locales (this might take a while)...
   en_US.UTF-8... done
Generation complete.

Note

locale-gen generate localisation files from templates (/etc/locales.gen).

@p-datadog
Copy link
Member

Would it be helpful to add a check that the needed locale actually got generated, i.e. locale -a|grep UTF-8, and that it's used by Ruby, e.g.

 test  "`ruby -e 'puts "".encoding'`" = UTF-8

?

@lloeki
Copy link
Member

lloeki commented Jul 3, 2024

@p-datadog I was thinking about that as well, if only to be able to check that this PR works as expected across the board by having it checking itself instead of going through this PR's generated images manually.

Let me create a quick and stupid test harness for that.

@lloeki
Copy link
Member

lloeki commented Jul 3, 2024

I've added a couple test cases and a test harness, failure on some older rubies is expected at this stage because of the minitest version. I'll improve a bit upon it.

EDIT: HA! It actually worked.

@lloeki lloeki force-pushed the tonycthsu/utf-8-encoding branch from e5a97fe to 2de9e4f Compare July 3, 2024 15:11
Copy link
Member

@p-datadog p-datadog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

@lloeki lloeki merged commit d7f9a0e into main Jul 3, 2024
16 checks passed
@lloeki lloeki deleted the tonycthsu/utf-8-encoding branch July 3, 2024 19:07
@lloeki
Copy link
Member

lloeki commented Jul 3, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants