On 06/21/2018 12:07 PM, codewiz...@gmail.com wrote:
On Thursday, June 21, 2018 at 1:08:35 PM UTC-4, Ethan Furman wrote:
I need to translate numeric data in a string format into a binary format. I
know there are at least two different
methods of representing parts less that 1, such as "10.5" and "10,5". The data
is encoded using code pages, and can
vary depending on the file being read (so I can't rely on current locale
settings).
I'm sure this is a solved problem, but I'm not finding those solutions. Any
pointers?
Try this StackOverflow answer: https://stackoverflow.com/a/17815252
--> import locale
--> a = u'545,545.2222'
--> locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
'en_US.UTF-8'
The problem there is it sets the locale for the entire process -- I just need the conversion step for individual pieces
of data without modifying the user's settings.
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list