[SOLVED] makemkvcon and utf 8 character from bash script

Discussion of advanced MakeMKV functionality, expert mode, conversion profiles
Post Reply
eelisland
Posts: 9
Joined: Fri Mar 14, 2014 6:01 pm

[SOLVED] makemkvcon and utf 8 character from bash script

Post by eelisland »

When opened from the GUI, label is chown as attended:

Code: Select all

Belle et S?bastien
But when i run it from shell script

Code: Select all

CINFO:2,0,"Belle et S?©bastien"
CINFO:28,0,"eng"
CINFO:29,0,"English"
CINFO:30,0,"Belle et S?©bastien"
Don't know if it's relevant but i have tried to change my locale variable whithout success, default:

Code: Select all

~$ locale
LANG=en_US
LC_CTYPE="en_US"
LC_NUMERIC="en_US"
LC_TIME="en_US"
LC_COLLATE=C
LC_MONETARY="en_US"
LC_MESSAGES="en_US"
LC_PAPER="en_US"
LC_NAME="en_US"
LC_ADDRESS="en_US"
LC_TELEPHONE="en_US"
LC_MEASUREMENT="en_US"
LC_IDENTIFICATION="en_US"
LC_ALL=
i have tried

export LANG=en_US.UTF-8 and fr_FR.UTF-8, en_US.utf8, fr_FR.utf8

LC_CTYPE=us_US.UTF-8 and and fr_FR.UTF-8, en_US.utf8, fr_FR.utf8

LANG=en_US.UTF-8 myscript.sh

O.S is Slackware 14.0 64bit, i'm still searching on google, any help is welcome
Last edited by eelisland on Wed Apr 30, 2014 10:14 am, edited 3 times in total.
lightsabersetc
Posts: 28
Joined: Sat Dec 29, 2012 10:28 pm
Location: Las Vegas, NV
Contact:

Re: makemkvcon and utf 8 character from bash script

Post by lightsabersetc »

I've never used Slackware, but I'm pulling UTF-8 through with no issues on CentOS and Ubuntu. Locale changes won't take effect until you log out and back in, so I don't think that modifying the environment variables via CLI will work.. try editing your `/etc/profile.d/lang.sh` file instead. There was also a note at http://docs.slackware.com/slackware:localization in the per-user config section stating that Bash uses a different init script, but I think that is irrelevant with a system wide config. You should also be able to put the exports directly in your `~/.bashrc`.
kevmitch
Posts: 72
Joined: Mon Mar 11, 2013 6:35 am

Re: makemkvcon and utf 8 character from bash script

Post by kevmitch »

What exactly is this shell script you are referring to? And where exactly are you viewing the mojibaked output? Do you see the same problem, just running makemkvcon from the command line? You might also try different terminal emulators. In my limited encounters with non-ascii encoding, uxterm or urxvt were usually the best choice.
eelisland
Posts: 9
Joined: Fri Mar 14, 2014 6:01 pm

Re: makemkvcon and utf 8 character from bash script

Post by eelisland »

@Lightsabersetc

Thanks editing /etc/profile.d/lang.sh works fine after a full log off. I have edited with root, loged off the root session but not my user session :wink:

Code: Select all

export LANG=en_US.UTF-8
@kevmitch

My script is executing makemkvcon -r info to file and then the file is parsed in a bash while loop with cases to extract various information like label, duration etc...
eelisland
Posts: 9
Joined: Fri Mar 14, 2014 6:01 pm

Re: makemkvcon and utf 8 character from bash script

Post by eelisland »

Just for the little story, the makemkvcon file still contain thoses strange characteres but they are now well handled by bash, here a sample of the script output in debug mode ( -x )

Code: Select all

+ read -ra fields
+ case ${fields[0]} in
+ bd_name[0]='Belle et S?©bastien'
+ IFS='"'
+ read -ra fields
+ case ${fields[0]} in
+ IFS='"'
+ read -ra fields
+ case ${fields[0]} in
+ IFS='"'
+ read -ra fields
+ case ${fields[0]} in
+ bd_name[1]='Belle et S?©bastien'
+ break
+ [[ -n '' ]]
+ [[ 2 -eq 0 ]]
+ [[ 2 -ge 1 ]]
+ [[ -n Belle et S?©bastien ]]
+ final_name='Belle et S?©bastien'
+ [[ 2 -ge 1 ]]
+ [[ ! -n Belle et S?©bastien ]]
+ [[ 2 -ge 1 ]]
+ [[ ! -n Belle et S?©bastien Belle et S?©bastien ]]
++ format_name 'Belle et S?©bastien'
++ final_name='Belle et S?©bastien'
++ final_name=(${final_name,,})
++ final_name='Belle Et S?©bastien'
++ [[ . != '' ]]
++ final_name=$'Belle.Et.S\303\251bastien'
++ echo $'Belle.Et.S\303\251bastien'
lightsabersetc
Posts: 28
Joined: Sat Dec 29, 2012 10:28 pm
Location: Las Vegas, NV
Contact:

Re: [SOLVED] makemkvcon and utf 8 character from bash script

Post by lightsabersetc »

Glad to hear that it worked. The garbled characters you are seeing just mean that one of the applications in the stack (screen, nano, xterm, etc.) are not setup to handle UTF-8. You can either track down the specific app, or just ignore it. Also if you are saving to a file, it's possible that the file is being written in a different encoding. You can check file encoding with `file --mime myfile.txt`.
Post Reply