Bitbar: Text encoding

Created on 8 Jan 2016  ·  11Comments  ·  Source: matryer/bitbar

I have some spanish text, how can I show them?, I get something like this in the dropdown:

Bajo el m?195?161ximo de CPUs de 8 a 6

And the correct text would:

Bajo el máximo de CPUs de 8 a 6

I'm using bash.

Thanks,

wtf⁉

Most helpful comment

Hit a similar problem with python. Something like #!/usr/bin/env PYTHONIOENCODING=UTF-8 /usr/local/bin/python3 seems to fix it.

All 11 comments

I don't know the answer to that question - can you try it and let us know what it does?

captura de pantalla 2016-01-08 a las 10 12 00

I have an script in bash that execute a svn log command. Commit message is in Spanish and has accents. I don´t know how to show it the correct way.

I don’t know either - this one is going to take some investigation.

On 8 Jan 2016, at 09:16, Fco. Javier Martín Carrasco [email protected] wrote:

https://cloud.githubusercontent.com/assets/454310/12194466/9c97802c-b5f0-11e5-8293-5b700a9f1e1d.png
I have an script in bash that execute a svn log command. Commit message is in Spanish and has accents. I don´t know how to show it the correct way.


Reply to this email directly or view it on GitHub https://github.com/matryer/bitbar/issues/141#issuecomment-169943251.

I have found the solution:

export LANG="es_ES.UTF-8"

I put that first in the bash script and it works.

Thanks.

Oh great nice one - maybe you could submit a PR with that documented in the README.md?

The issue is that the language isn't being loaded via locales

I've added to my clipboard plugin

# Hack for language not being set properly and unicode support
export LANG="${LANG:-en_US.UTF-8}"

should this be a fix in BitBar itself?

It might be possible.

Get the user's current local string in an LC format with UTF-8:

NSLocale * currentLocale = [NSLocale currentLocale];
NSString * localeString = [NSString stringWithFormat:@"%@_%@.UTF-8", (NSString*)[currentLocale objectForKey:NSLocaleLanguageCode], (NSString*)[currentLocale objectForKey:NSLocaleCountryCode]];
NSLog(@"localeIdentifier: %@", localeString);

Should output localeIdentifier: en_US.UTF-8 for me.

Then you should be able to set that environment variable for the task with something like this:

NSMutableDictionary *env = [task environment];
[environment setObject:localeString
forKey:@"LC_ALL"];

Can't try this out right now since I'm not running my full Xcode environment on this machine.

Opened pull request #146 which works for me.

Hit a similar problem with python. Something like #!/usr/bin/env PYTHONIOENCODING=UTF-8 /usr/local/bin/python3 seems to fix it.

If using python 2:

#!/usr/bin/env PYTHONIOENCODING=UTF-8 /usr/local/bin/python
# -*- coding: utf-8 -*-
print u'blah'
Was this page helpful?
0 / 5 - 0 ratings

Related issues

JayBrown picture JayBrown  ·  11Comments

phaistonian picture phaistonian  ·  4Comments

cjbaar picture cjbaar  ·  10Comments

alesf picture alesf  ·  7Comments

JayBrown picture JayBrown  ·  9Comments