There are now some files which contain raw bytes which are valid UTF-8 characters, e.g. a line of the file could be '@\u0915\u0941\u091b@ \u092c\u093f\u0902\u0926\u0941 \u0938\u095e\u0947\u0926 \u0939\u0948\u0902'

I want to restore them to their original UTF-8 strings and save the files.

Is there a way to do it in Emacs?

  • Are those UTF-8 encoded characters, or unicode code points (looks like the latter)? – npostavs Jul 15 '17 at 20:05
  • I don't think you're actually talking about arrays, but if you were then stackoverflow.com/questions/43987299/utf-8-bytes-to-string would be a near-duplicate. You seem to be talking about buffers with incorrect character encoding? Reading C-h i g (emacs)Specify Coding may help? – phils Jul 15 '17 at 20:39
  • @phils I don't think so. I set the encoding of the buffer to UTF-8. The characters simply don't get displayed correctly. It's a really strange issue. I just want to work on the characters in R, but R displays them literally as raw bytes, alongside with other English characters. If I manually copy it into R Console surrounded with quotes, it works. I just don't know why. But anyways I want to get them displayed/interpreted as normal strings no matter what's the cause of the issue. Emacs is the tool I use daily so I was seeking for a solution with it. – xji Jul 15 '17 at 23:26
  • @npostavs If I type them into R Console I get "@कुछ@ बिंदु सफ़ेद हैं". Guess they are complete characters then? This example should be Hindi. – xji Jul 15 '17 at 23:26
  • 1
    Okay, I'm a bit confused what bytes the file contains, does it literally have \ u 0 9 1 5, or is that just meta-syntax you're using to talk about the character "DEVANAGARI LETTER KA"? What do you get if you put the cursor on that letter and do C-u C-x =? – npostavs Jul 16 '17 at 0:00

Your Answer

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

Browse other questions tagged or ask your own question.