Ticket #2282 (reopened enhancement)
force utf option
Reported by: | zyxmon | Owned by: | |
---|---|---|---|
Priority: | trivial | Milestone: | Future Releases |
Component: | mc-tty | Version: | master |
Keywords: | Cc: | ||
Blocked By: | Blocking: | ||
Branch state: | no branch | Votes for changeset: |
Description
I have arm based nas (synology ds110j), that does not support locales but stores files in uft-8.
The sample program
#include <langinfo.h> #include <locale.h> #include <stdio.h> int main (int argc, char *argv[]) { setlocale (LC_ALL, ""); printf ("%s\n", nl_langinfo (CODESET)); return 0; }
always returns ANSI_X3.4-1968
To make mc correctly work with utf-8 on this system I've made changes in 2 files:
1) In lib/strutil/strutil.c
I've changed
return (nl_langinfo (CODESET));
to
return "UTF8";
2) In lib\tty\tty-slang.c
I've changed
SLutf8_enable (-1);
to
SLutf8_enable (1);
These changes force utf-8 support in mc on my system.
I think these changes can be made an option in future releases in mc for such systems.
PS Many thanks to il.smind, who helped my to find this solution.
Attachments
Change History
comment:1 Changed 14 years ago by andrew_b
- Status changed from new to closed
- Resolution set to wontfix
- Version 4.7.3 deleted
- Component changed from mc-core to mc-tty
- Milestone 4.7 deleted
comment:2 Changed 14 years ago by angel_il
- Status changed from closed to reopened
- Resolution wontfix deleted
need fix FAQ and maybe add patch into 'contrib'
comment:3 Changed 14 years ago by angel_il
- Priority changed from major to minor
- Version set to master
- Milestone set to 4.7.4
comment:5 Changed 14 years ago by zyxmon
Just a small remark on my patches. The correct fix for lib/strutil/strutil.c is
return "UTF-8";
These patches also helped to show nonascii chars on mc compiled for mipsel based router.
comment:6 Changed 14 years ago by andrew_b
Again, if your OS supports UTF-8, but nl_langinfo (CODESET) returnes not "UTF-8" string, then OS itself should be fixed not MC.
comment:7 follow-up: ↓ 8 Changed 14 years ago by zyxmon
The nl_langinfo on the mipsel router retured "ascii", so this patch was needed.
comment:8 in reply to: ↑ 7 Changed 14 years ago by andrew_b
Replying to zyxmon:
The nl_langinfo on the mipsel router retured "ascii"
Yes. I'm talking about that. In any case, this bug in not in MC but in target OS. Do you agree with me?
so this patch was needed.
If your OS has some package management system, you can build the MC package with this OS-specific patch, can't you?
comment:9 Changed 14 years ago by zyxmon
I totally agree with you, this is not a bug in MC. My last remark was just a small correction for the first post. The correct encoding name is "UTF-8". "UTF8" may be just an alias to "UTF-8".
These are OS specific patches.
comment:10 Changed 14 years ago by zyxmon
I have added two patches for mc-4.7.5.1 just in case one has such an OS and needs them.
They will work for optware and openwrt package systems. Openwrt Makefile for mc needs a lot of changes for building mc-4.7.5.1 with slang2 for these patches to work.
comment:11 Changed 13 years ago by andrew_b
- Priority changed from minor to trivial
- Branch state set to no branch
- Milestone changed from 4.7.5 to Future Releases
It's terrible. This durty hack cannot be applied in MC.