Opened 12 years ago
Closed 10 years ago
#9696 closed bug (fixed)
cal command not aware of UTF-8 strings
Reported by: | un_spacyar | Owned by: | nobody |
---|---|---|---|
Priority: | normal | Milestone: | R1 |
Component: | Applications | Version: | R1/alpha4.1 |
Keywords: | cal | Cc: | |
Blocked By: | Blocking: | ||
Platform: | x86 |
Description
Hello! When type ' cal ' command in the Terminal, the app show the first row of days misaligned (please, see attachment).
Attachments (2)
Change History (9)
by , 12 years ago
Attachment: | cal_command.png added |
---|
comment:1 by , 12 years ago
Component: | - General → Kits/Locale Kit |
---|---|
Owner: | changed from | to
comment:2 by , 12 years ago
Which locale is it ? It looks like the two-letter code for saturday is "s\n" or something similar, leading to the cursor not going to the next line like it should. The day names come from ICU data, maybe we need to update our version of it.
comment:3 by , 12 years ago
No idea what was the original locale, but Galego (Espana) - has the same issue.
the last byte at days names line is 0xC3 that is 11000011. In UTF-8 encoding it should be the first byte of the 2-bytes character - so the next CR is obviously eaten as parto of it. By the way the Terminal capture log show that lines are ended with CRLF that is also looking a bit suspicious. ;-)
comment:4 by , 12 years ago
Component: | Kits/Locale Kit → Applications |
---|---|
Keywords: | Terminal removed |
Owner: | changed from | to
Summary: | Terminal - cal command show misaligned text → cal command not aware of UTF-8 strings |
"cal" blindly truncate the (correct) string returned by strftime. I'm not sure what to do, fixing this properly requires use of wchar strings, and I'm not sure we can use them with gcc2 and our old glibc.
We should use wcsftime() to format the days in unicode, and grab 2 unicode chars (not 2 bytes) from that. Or find a way to get 2-letter names for the days in a better way. One solution would be to rewrite cal into C++ and use the Locale Kit and BString. Code could be simpler.
comment:5 by , 12 years ago
in response to pulkomandy; my locale settings are "Spanish (Argentina)". If you need more info or testing, just ask. Thank you!
comment:6 by , 10 years ago
The GNU implementation of cal may be used (as an outsourced package). I tried to find fixes for the version we have elsewhere but I could only find either simpler (in retrobsd) or more complex (openbsd, minix, freebsd) versions.
http://www.gnu.org/software/gcal/
I'm adding a gci task for writing a recipe for it.
comment:7 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Fixed in hrev48506. You need to install the gcal package to get the command again.
Based on some tests, appears to be locale-specific.