Skip to contentSkip to conversation

Git messes up 'ø' character

DISCUSSION Noralf Trønnes 7 participants 14 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

I can't get my name: Noralf Trønnes, to come out correctly when I format and send a patch. The 'ø' becomes a question mark when received in my email client.

This is the head of the patch file generated by git format-patch:

From b2a4f6abdb097c4dc092b56995a2af8e42fbea79 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Noralf=20Tr=F8nnes?= <[email protected]>
Date: Tue, 20 Jan 2015 18:34:47 +0100
Subject: [PATCH] staging: fbtft: remove ARCH_BCM2708 optimization
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

ARCH_BCM2708 is not present in mainline so remove optimization.

---

$ git log -1
commit b2a4f6abdb097c4dc092b56995a2af8e42fbea79
Author: Noralf Tr<F8>nnes <[email protected]>
Date:   Tue Jan 20 18:34:47 2015 +0100

staging: fbtft: remove ARCH_BCM2708 optimization

ARCH_BCM2708 is not present in mainline so remove optimization.

$ git send-email --to [email protected] 0001-staging-fbtft-remove-ARCH_BCM2708-optimization.patch
0001-staging-fbtft-remove-ARCH_BCM2708-optimization.patch
(mbox) Adding cc: =?UTF-8?q?Noralf=20Tr=F8nnes?= <[email protected]> from line 'From: =?UTF-8?q?Noralf=20Tr=F8nnes?= <[email protected]>'
(body) Adding cc: Noralf Trønnes <[email protected]> from line 'Signed-off-by: Noralf Trønnes <[email protected]>'

From: =?UTF-8?q?Noralf=20Tr=F8nnes?= <[email protected]>
To: [email protected]
Subject: [PATCH] staging: fbtft: remove ARCH_BCM2708 optimization
Date: Tue, 20 Jan 2015 20:25:24 +0100
Message-Id: <[email protected]>
X-Mailer: git-send-email 2.2.2
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The Cc list above has been expanded by additional addresses found in the patch commit message. By default send-email prompts before sending whenever this occurs. This behavior is controlled by the sendemail.confirm configuration setting.

For additional information, run 'git send-email --help'. To retain the current behavior, but squelch this message, run 'git config --global sendemail.confirm auto'.

Send this email? ([y]es|[n]o|[q]uit|[a]ll): y
OK. Log says:
Server: smtp.ebnett.no
MAIL FROM:<[email protected]>
RCPT TO:<[email protected]>
From: =?UTF-8?q?Noralf=20Tr=F8nnes?= <[email protected]>
To: [email protected]
Subject: [PATCH] staging: fbtft: remove ARCH_BCM2708 optimization
Date: Tue, 20 Jan 2015 20:44:15 +0100
Message-Id: <[email protected]>
X-Mailer: git-send-email 2.2.2
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Result: 250 2.0.0 Ok: queued as B49BB8014D

Setup:

Ubuntu server

$ cat /etc/issue
Ubuntu 12.04.3 LTS \n \l
$ git --version
git version 2.2.2
$ git config -l
user.name=Noralf Trønnes
[email protected]
core.editor=nano
alias.serve=daemon --verbose --export-all --base-path=/home/pi --reuseaddr
sendemail.smtpserver=smtp.ebnett.no
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
remote.origin.url=git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git
branch.master.remote=origin
branch.master.merge=refs/heads/master
branch.staging-testing.remote=origin
branch.staging-testing.merge=refs/heads/staging-testing

Regards,
Noralf Trønnes

#1 lore raw

On 2015-01-20 20.46, Noralf Trønnes wrote:
could it be that your "ø" is not encoded as UTF-8, but in ISO-8859-15 (or so)

Quoted 3 lines
$ git log -1
commit b2a4f6abdb097c4dc092b56995a2af8e42fbea79
Author: Noralf Tr<F8>nnes <[email protected]>

What does
git config -l | grep Noralf | xxd
say ?

#2 lore raw

Den 20.01.2015 21:07, skrev Torsten Bögershausen:

Quoted 11 lines · Noralf Trønnes

could it be that your "ø" is not encoded as UTF-8, but in ISO-8859-15 (or so)

Quoted 3 lines
$ git log -1
commit b2a4f6abdb097c4dc092b56995a2af8e42fbea79
Author: Noralf Tr<F8>nnes <[email protected]>

What does
git config -l | grep Noralf | xxd
say ?

$ git config -l | grep Noralf | xxd
0000000: 7573 6572 2e6e 616d 653d 4e6f 7261 6c66  user.name=Noralf
0000010: 2054 72f8 6e6e 6573 0a                    Tr.nnes.
$ file ~/.gitconfig
/home/pi/.gitconfig: ISO-8859 text
#3 lore raw
Quoted 14 lines · Noralf Trønnes

Den 20.01.2015 21:07, skrev Torsten Bögershausen:

Quoted 13 lines · Noralf Trønnes

could it be that your "ø" is not encoded as UTF-8, but in ISO-8859-15 (or so)

Quoted 3 lines
$ git log -1
commit b2a4f6abdb097c4dc092b56995a2af8e42fbea79
Author: Noralf Tr<F8>nnes <[email protected]>

What does
git config -l | grep Noralf | xxd
say ?

Quoted 6 lines
$ git config -l | grep Noralf | xxd
0000000: 7573 6572 2e6e 616d 653d 4e6f 7261 6c66  user.name=Noralf
0000010: 2054 72f8 6e6e 6573 0a                    Tr.nnes.
$ file ~/.gitconfig
/home/pi/.gitconfig: ISO-8859 text

What's happened here is that:

1. You've authored your commit in ISO-8859-1
2. Git itself has no place for the encoding of the author name in the
commit object format
3. git-format-patch has a --compose-encoding which I think would sort
this out if you set it to ISO-8859-1, but it defaults to UTF-8
4. Your patch is actually a ISO-8859-1 byte sequence, but is
advertised as UTF-8
5. You end up with a screwed-up commit

You could work around this, but I suggest just joining the 21st century and working exclusively in UTF-8, it makes things much easier, speaking as someone with 3x more non-ASCII characters their his name than you :)

#4 lore raw
Quoted 33 lines · Ævar Arnfjörð Bjarmason
Quoted 14 lines · Noralf Trønnes

Den 20.01.2015 21:07, skrev Torsten Bögershausen:

Quoted 13 lines · Noralf Trønnes

could it be that your "ø" is not encoded as UTF-8, but in ISO-8859-15 (or so)

Quoted 3 lines
$ git log -1
commit b2a4f6abdb097c4dc092b56995a2af8e42fbea79
Author: Noralf Tr<F8>nnes <[email protected]>

What does
git config -l | grep Noralf | xxd
say ?

Quoted 6 lines
$ git config -l | grep Noralf | xxd
0000000: 7573 6572 2e6e 616d 653d 4e6f 7261 6c66  user.name=Noralf
0000010: 2054 72f8 6e6e 6573 0a                    Tr.nnes.
$ file ~/.gitconfig
/home/pi/.gitconfig: ISO-8859 text

What's happened here is that:

1. You've authored your commit in ISO-8859-1
2. Git itself has no place for the encoding of the author name in the
commit object format
3. git-format-patch has a --compose-encoding which I think would sort
this out if you set it to ISO-8859-1, but it defaults to UTF-8
4. Your patch is actually a ISO-8859-1 byte sequence, but is
advertised as UTF-8
5. You end up with a screwed-up commit

Quoted 4 lines

You could work around this, but I suggest just joining the 21st century and working exclusively in UTF-8, it makes things much easier, speaking as someone with 3x more non-ASCII characters their his name than you :)

So how exactly do you fix this using UTF-8? Git is exporting a UTF-8 "From:" line so it thinks the character is correct, but it's not creating something properly here.

confused,

greg k-h

#5 lore raw
In reply to Ævar Arnfjörð Bjarmason
Quoted 5 lines · Ævar Arnfjörð Bjarmason

What's happened here is that:

1. You've authored your commit in ISO-8859-1
2. Git itself has no place for the encoding of the author name in the
commit object format

Is (2) right? The "encoding" header in a commit object should apply not just to the commit message, but also to the author (and committer) name.

I think the real problem is simply that it defaults to UTF-8, but he is giving it iso-8859-1 characters. Setting i18n.commitEncoding should fix it.

-Peff

PS If you try experimenting with this, you may fall afoul of 08a94a1
(commit/commit-tree: correct latin1 to utf-8, 2012-06-28), which will silently "correct" Latin1 characters into UTF-8 (when the commit message is expected to be in UTF-8, of course). So it actually _should_ just work under modern gits, but only for Latin1.

#6 lore raw
Quoted 8 lines · Jeff King
Quoted 5 lines · Ævar Arnfjörð Bjarmason

What's happened here is that:

1. You've authored your commit in ISO-8859-1
2. Git itself has no place for the encoding of the author name in the
commit object format

Quoted 6 lines

Is (2) right? The "encoding" header in a commit object should apply not just to the commit message, but also to the author (and committer) name.

I think the real problem is simply that it defaults to UTF-8, but he is giving it iso-8859-1 characters. Setting i18n.commitEncoding should fix it.

True, I forgot about that setting.

Quoted 7 lines

-Peff

PS If you try experimenting with this, you may fall afoul of 08a94a1
(commit/commit-tree: correct latin1 to utf-8, 2012-06-28), which will silently "correct" Latin1 characters into UTF-8 (when the commit message is expected to be in UTF-8, of course). So it actually _should_ just work under modern gits, but only for Latin1.

#7 lore raw
In reply to Ævar Arnfjörð Bjarmason

Den 20.01.2015 21:45, skrev Ævar Arnfjörð Bjarmason:

Quoted 30 lines · Noralf Trønnes
Quoted 12 lines

Den 20.01.2015 21:07, skrev Torsten Bögershausen:

Quoted 11 lines · Noralf Trønnes

could it be that your "ø" is not encoded as UTF-8, but in ISO-8859-15 (or so)

Quoted 3 lines
$ git log -1
commit b2a4f6abdb097c4dc092b56995a2af8e42fbea79
Author: Noralf Tr<F8>nnes <[email protected]>

What does
git config -l | grep Noralf | xxd
say ?

Quoted 6 lines
$ git config -l | grep Noralf | xxd
0000000: 7573 6572 2e6e 616d 653d 4e6f 7261 6c66  user.name=Noralf
0000010: 2054 72f8 6e6e 6573 0a                    Tr.nnes.
$ file ~/.gitconfig
/home/pi/.gitconfig: ISO-8859 text

What's happened here is that:

1. You've authored your commit in ISO-8859-1
2. Git itself has no place for the encoding of the author name in the
commit object format
3. git-format-patch has a --compose-encoding which I think would sort
this out if you set it to ISO-8859-1, but it defaults to UTF-8
4. Your patch is actually a ISO-8859-1 byte sequence, but is
advertised as UTF-8
5. You end up with a screwed-up commit

Quoted 5 lines

You could work around this, but I suggest just joining the 21st century and working exclusively in UTF-8, it makes things much easier, speaking as someone with 3x more non-ASCII characters their his name than you :)

Ok, then the question is: How do I switch to UTF-8?

To me it seems I'm already using it:

$ locale charmap
UTF-8
#8 lore raw
Quoted 42 lines · Noralf Trønnes

Den 20.01.2015 21:45, skrev Ævar Arnfjörð Bjarmason:

Quoted 34 lines · Noralf Trønnes
Quoted 15 lines

Den 20.01.2015 21:07, skrev Torsten Bögershausen:

Quoted 13 lines · Noralf Trønnes

could it be that your "ø" is not encoded as UTF-8, but in ISO-8859-15 (or so)

Quoted 3 lines
$ git log -1
commit b2a4f6abdb097c4dc092b56995a2af8e42fbea79
Author: Noralf Tr<F8>nnes <[email protected]>

What does
git config -l | grep Noralf | xxd
say ?

Quoted 6 lines
$ git config -l | grep Noralf | xxd
0000000: 7573 6572 2e6e 616d 653d 4e6f 7261 6c66  user.name=Noralf
0000010: 2054 72f8 6e6e 6573 0a                    Tr.nnes.
$ file ~/.gitconfig
/home/pi/.gitconfig: ISO-8859 text

What's happened here is that:

1. You've authored your commit in ISO-8859-1
2. Git itself has no place for the encoding of the author name in the
commit object format
3. git-format-patch has a --compose-encoding which I think would sort
this out if you set it to ISO-8859-1, but it defaults to UTF-8
4. Your patch is actually a ISO-8859-1 byte sequence, but is
advertised as UTF-8
5. You end up with a screwed-up commit

Quoted 5 lines

You could work around this, but I suggest just joining the 21st century and working exclusively in UTF-8, it makes things much easier, speaking as someone with 3x more non-ASCII characters their his name than you :)

Quoted 5 lines

Ok, then the question is: How do I switch to UTF-8?

To me it seems I'm already using it:

$ locale charmap
UTF-8

Your .gitconfig has an ISO-8859-1 string, from an earlier mail of yours:

Quoted 3 lines
$ git config -l | grep Noralf | xxd
0000000: 7573 6572 2e6e 616d 653d 4e6f 7261 6c66  user.name=Noralf
0000010: 2054 72f8 6e6e 6573 0a                    Tr.nnes.

On a system configured for UTF-8 this would be:

$ echo Noralf Trønnes | xxd
0000000: 4e6f 7261 6c66 2054 72c3 b86e 6e65 730a  Noralf Tr..nnes.

Note the "f8" v.s. "c3 b8".

#9 lore raw

Den 20.01.2015 22:26, skrev Ævar Arnfjörð Bjarmason:

Quoted 48 lines · Noralf Trønnes
Quoted 37 lines

Den 20.01.2015 21:45, skrev Ævar Arnfjörð Bjarmason:

Quoted 30 lines · Noralf Trønnes
Quoted 12 lines

Den 20.01.2015 21:07, skrev Torsten Bögershausen:

Quoted 11 lines · Noralf Trønnes

could it be that your "ø" is not encoded as UTF-8, but in ISO-8859-15 (or so)

Quoted 3 lines
$ git log -1
commit b2a4f6abdb097c4dc092b56995a2af8e42fbea79
Author: Noralf Tr<F8>nnes <[email protected]>

What does
git config -l | grep Noralf | xxd
say ?

Quoted 6 lines
$ git config -l | grep Noralf | xxd
0000000: 7573 6572 2e6e 616d 653d 4e6f 7261 6c66  user.name=Noralf
0000010: 2054 72f8 6e6e 6573 0a                    Tr.nnes.
$ file ~/.gitconfig
/home/pi/.gitconfig: ISO-8859 text

What's happened here is that:

1. You've authored your commit in ISO-8859-1
2. Git itself has no place for the encoding of the author name in the
commit object format
3. git-format-patch has a --compose-encoding which I think would sort
this out if you set it to ISO-8859-1, but it defaults to UTF-8
4. Your patch is actually a ISO-8859-1 byte sequence, but is
advertised as UTF-8
5. You end up with a screwed-up commit

Quoted 5 lines

You could work around this, but I suggest just joining the 21st century and working exclusively in UTF-8, it makes things much easier, speaking as someone with 3x more non-ASCII characters their his name than you :)

Quoted 5 lines

Ok, then the question is: How do I switch to UTF-8?

To me it seems I'm already using it:

$ locale charmap
UTF-8

Your .gitconfig has an ISO-8859-1 string, from an earlier mail of yours:

Quoted 3 lines
$ git config -l | grep Noralf | xxd
0000000: 7573 6572 2e6e 616d 653d 4e6f 7261 6c66  user.name=Noralf
0000010: 2054 72f8 6e6e 6573 0a                    Tr.nnes.
Quoted 7 lines

On a system configured for UTF-8 this would be:

$ echo Noralf Trønnes | xxd
0000000: 4e6f 7261 6c66 2054 72c3 b86e 6e65 730a  Noralf Tr..nnes.

Note the "f8" v.s. "c3 b8".

Yes:

$ echo Noralf Trønnes | xxd
0000000: 4e6f 7261 6c66 2054 72f8 6e6e 6573 0a    Noralf Tr.nnes.

Is there a command I can run that shows that I'm using ISO-8859-1 ?
I need something to google with, my previous search only gave locale stuff, which seems fine.

#10 lore raw
Quoted 7 lines · Noralf Trønnes

Yes:

$ echo Noralf Trønnes | xxd
0000000: 4e6f 7261 6c66 2054 72f8 6e6e 6573 0a    Noralf Tr.nnes.

Is there a command I can run that shows that I'm using ISO-8859-1 ? I need something to google with, my previous search only gave locale stuff, which seems fine.

The locale(1) command tells you what your locale is set to, but it doesn't say anything about your input method -- it only tells you what your shell and commands started from it expect for input and what they should produce for output.

The input method will generally be part of your windowing environment, for which you'll have to search how to check/configure your OS (sometimes it can be set on a per-window basis, sometimes it's a global setting).

Even if the windowing environment is set to UTF-8, your terminal emulator might be set to ISO-8859-something, so check the terminal emulator (e.g., rxvt, Terminator, GNOME Terminal, PuTTY, ...).

Finally, check what stty(1) says (e.g., on Linux it should show that iutf8 is enabled) (this is mostly so that when you backspace in cooked mode the line discipline knows how many bytes to drop from the buffer).

Nico

#11 lore raw

Den 20.01.2015 23:18, skrev Nico Williams:

Quoted 13 lines · Noralf Trønnes
Quoted 7 lines

Yes:

$ echo Noralf Trønnes | xxd
0000000: 4e6f 7261 6c66 2054 72f8 6e6e 6573 0a    Noralf Tr.nnes.

Is there a command I can run that shows that I'm using ISO-8859-1 ? I need something to google with, my previous search only gave locale stuff, which seems fine.

The locale(1) command tells you what your locale is set to, but it doesn't say anything about your input method -- it only tells you what your shell and commands started from it expect for input and what they should produce for output.

Quoted 8 lines

The input method will generally be part of your windowing environment, for which you'll have to search how to check/configure your OS (sometimes it can be set on a per-window basis, sometimes it's a global setting).

Even if the windowing environment is set to UTF-8, your terminal emulator might be set to ISO-8859-something, so check the terminal emulator (e.g., rxvt, Terminator, GNOME Terminal, PuTTY, ...).

I use putty which was set to ISO-8859-1. Changing this to UTF-8 gave me the correct result:

$ echo Noralf Trønnes | xxd
0000000: 4e6f 7261 6c66 2054 72c3 b86e 6e65 730a  Noralf Tr..nnes.

Thank you all for helping me!

#13 lore raw
In reply to Noralf Trønnes
Quoted 67 lines · Noralf Trønnes

Den 20.01.2015 22:26, skrev Ævar Arnfjörð Bjarmason:

Quoted 57 lines
Quoted 43 lines · Noralf Trønnes

Den 20.01.2015 21:45, skrev Ævar Arnfjörð Bjarmason:

Quoted 35 lines
Quoted 15 lines · Noralf Trønnes

Den 20.01.2015 21:07, skrev Torsten Bögershausen:

Quoted 13 lines · Noralf Trønnes

could it be that your "ø" is not encoded as UTF-8, but in ISO-8859-15 (or so)

Quoted 3 lines
$ git log -1
commit b2a4f6abdb097c4dc092b56995a2af8e42fbea79
Author: Noralf Tr<F8>nnes <[email protected]>

What does
git config -l | grep Noralf | xxd
say ?

Quoted 6 lines
$ git config -l | grep Noralf | xxd
0000000: 7573 6572 2e6e 616d 653d 4e6f 7261 6c66  user.name=Noralf
0000010: 2054 72f8 6e6e 6573 0a                    Tr.nnes.
$ file ~/.gitconfig
/home/pi/.gitconfig: ISO-8859 text

What's happened here is that:

1. You've authored your commit in ISO-8859-1
2. Git itself has no place for the encoding of the author name in the
commit object format
3. git-format-patch has a --compose-encoding which I think would sort
this out if you set it to ISO-8859-1, but it defaults to UTF-8
4. Your patch is actually a ISO-8859-1 byte sequence, but is
advertised as UTF-8
5. You end up with a screwed-up commit

Quoted 5 lines

You could work around this, but I suggest just joining the 21st century and working exclusively in UTF-8, it makes things much easier, speaking as someone with 3x more non-ASCII characters their his name than you :)

Quoted 5 lines

Ok, then the question is: How do I switch to UTF-8?

To me it seems I'm already using it:

$ locale charmap
UTF-8

Your .gitconfig has an ISO-8859-1 string, from an earlier mail of yours:

Quoted 3 lines
$ git config -l | grep Noralf | xxd
0000000: 7573 6572 2e6e 616d 653d 4e6f 7261 6c66  user.name=Noralf
0000010: 2054 72f8 6e6e 6573 0a                    Tr.nnes.
Quoted 7 lines

On a system configured for UTF-8 this would be:

$ echo Noralf Trønnes | xxd
0000000: 4e6f 7261 6c66 2054 72c3 b86e 6e65 730a  Noralf Tr..nnes.

Note the "f8" v.s. "c3 b8".

Quoted 7 lines

Yes:

$ echo Noralf Trønnes | xxd
0000000: 4e6f 7261 6c66 2054 72f8 6e6e 6573 0a    Noralf Tr.nnes.

Is there a command I can run that shows that I'm using ISO-8859-1 ? I need something to google with, my previous search only gave locale stuff, which seems fine.

What does this give you, this is UTF-8.

$ echo git commit --author="Noralf Trønnes <[email protected]>" | xxd
0000000: 6769 7420 636f 6d6d 6974 202d 2d61 7574  git commit --aut
0000010: 686f 723d 4e6f 7261 6c66 2054 72c3 b86e  hor=Noralf Tr..n
0000020: 6e65 7320 3c6e 6f74 726f 4074 726f 6e6e  nes <notro@tronn
0000030: 6573 2e6f 7267 3e0a                      es.org>.

To see if you're using UTF-8 just look at the codepoints for the non-ASCII characters you're using and check if they're valid UTF-8. E.g. you can check this out:
http://en.wikipedia.org/wiki/%C3%98#Computers

Which shows you that the UTF-8 hex version is C3 B8, but the Latin-1 is F8, you're emitting F8, I'm emitting C3 B8.

#12 lore raw
In reply to Noralf Trønnes

Noralf Trønnes schrieb am 20.01.2015 um 23:26:

Quoted 23 lines

Den 20.01.2015 23:18, skrev Nico Williams:

Quoted 13 lines · Noralf Trønnes
Quoted 7 lines

Yes:

$ echo Noralf Trønnes | xxd
0000000: 4e6f 7261 6c66 2054 72f8 6e6e 6573 0a    Noralf Tr.nnes.

Is there a command I can run that shows that I'm using ISO-8859-1 ? I need something to google with, my previous search only gave locale stuff, which seems fine.

The locale(1) command tells you what your locale is set to, but it doesn't say anything about your input method -- it only tells you what your shell and commands started from it expect for input and what they should produce for output.

Quoted 8 lines

The input method will generally be part of your windowing environment, for which you'll have to search how to check/configure your OS (sometimes it can be set on a per-window basis, sometimes it's a global setting).

Even if the windowing environment is set to UTF-8, your terminal emulator might be set to ISO-8859-something, so check the terminal emulator (e.g., rxvt, Terminator, GNOME Terminal, PuTTY, ...).

Quoted 7 lines

I use putty which was set to ISO-8859-1. Changing this to UTF-8 gave me the correct result:

$ echo Noralf Trønnes | xxd
0000000: 4e6f 7261 6c66 2054 72c3 b86e 6e65 730a  Noralf Tr..nnes.

Thank you all for helping me!

You can also check the encoding of your config file with

file .git/config

or ":set fileencoding" in vim. ":set fileencoding=utf8" would allow you to convert it easily.

(This assumes that the file does not mix encodings.)

Michael