1

I have a 10 Mb file containing \uXXXX characters. How can I decode this with Sublime Text?

Example:
enter image description here

  • You should link to the file or a shorten form of it put it on ge.tt because it's not clear what you're talking about – barlop Dec 16 '14 at 16:39
  • @barlop, here is the sample - pastebin.com/GT6Wtx6z – LA_ Dec 16 '14 at 18:40
1

There are a couple of different things you can try. First and foremost, you need to be using a Unicode font that supports the characters you want to display. This site on unicode.org is a good resource, and Google is quite helpful, as always. If you don't mind using a non-monospace font, Arial Unicode MS comes with Windows and has pretty good coverage. I believe the monospace font Consolas does as well.

Secondly, your operating system needs to be set up to display those characters - most modern ones are, but you may run into issues with some versions and setups of Windows.

In Sublime, make sure you're viewing the file in the correct mode - try File -> Reopen with Encoding -> UTF-8 or ... -> UTF-16LE (or BE, you can try both).

So, without knowing the exact contents of your file, how it was generated, and more details about your system, that's about the best I can do. Good luck!


EDIT

Based on the file you linked, it looks like this is the output of a Python 2 program, as the data seem to be some lists containing unicode strings (I'm a Python programmer, as it so happens). I looked up a couple of the codepoints mentioned, and they're all Cyrillic, so just about any modern font should handle them. The issue is that you're going to need a program to read in the file and translate the individual bytes. In case you're interested, the first full string (from ' to ') is:

Любимая акция вернулась! В ресторанах Евразия ""3 ролла по цене 1""! С 9 по 12 сентября! Только эти 4 дня! Подробности на evrasia.spb.ru, 88005050145 и 008

Without having the entire file, I can't parse the whole thing for you, but if you're a Python programmer you should know what to do (I'd recommend using Python 3, its Unicode support is much better than 2.x). If not, find the person who generated the file and ask them to decode the bytes for you.

  • Thanks for your answer. I use the latest version of OSX and there is no problem with Unicode characters display. I've added an example of the file to the comments of my question. – LA_ Dec 16 '14 at 18:41
  • @LA_ thanks for the link, that solved the problem. See my edit above for what to do. – MattDMo Dec 16 '14 at 18:58
  • Thanks. I am the person who generated the file (=it was bulk downloaded from the Google App Engine), I've already found the way how to decode it with Python. But still I am interested if I can do the same with Sublime (or with built-in Python console). – LA_ Dec 16 '14 at 19:03
  • @LA_ Sublime Text 3 is built on top of Python 3.3, so all you need to do is paste each string into the console and it'll display the correct encoding. However, this isn't really feasible for a 10MB file, so a plugin would work better. – MattDMo Dec 16 '14 at 19:06
  • can not I access the text of the opened file from the console? – LA_ Dec 16 '14 at 19:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.