how to convert it into utf-8?

P

Pen Ttt

in my linux comsole:
ghex2 /home/pt/myday
there is the first line content
AA3F3201861F0000D61F0000
would you mind to tell me how can convert it into utf-8?
 
A

Ammar Ali

[Note: parts of this message were removed to make it a legal post.]

in my linux comsole:
ghex2 /home/pt/myday
there is the first line content
AA3F3201861F0000D61F0000
would you mind to tell me how can convert it into utf-8?


I can't tell which unicode range those specific code points belong to, but
if you're sure the hex data represents utf-8, and I understand what you are
asking for correctly, try something like:

line.scan(/(....)/).each do |code_point|
puts code_point.pack('H*')
end

Depending on where the data is coming from, you might need to flip the bytes
to account for endianness. I don't believe that will be an issue on linux.

Hope it helps,
Ammar
 
B

Brian Candler

Pen said:
in my linux comsole:
ghex2 /home/pt/myday
there is the first line content
AA3F3201861F0000D61F0000
would you mind to tell me how can convert it into utf-8?

What do you meant "convert to utf-8"?

Those hex characters are very unlikely to be UTF-8. See
http://en.wikipedia.org/wiki/UTF-8

AA = second, third or fourth byte of multi-byte sequence
3F = single-byte character (?)
32 = single-byte character (2)
01 = single-byte character (ctrl-A)
86 = second, third or fourth byte of multi-byte sequence
1F = single-byte character (ctrl-?)
... etc

Apart from D6 there are no "start of n-byte sequence" characters

Try typing "file /home/pt/myday", which will attempt to identify what
sort of file you actually have.
 
P

Pen Ttt

would you mind to tell me your email? i can send the data file to
you,please help me,think you in advance.
 
B

Brian Candler

Pen said:
pt@pt-laptop:~$ file /home/pt/myday
/home/pt/myday: data

'file' knows many file formats - look at /usr/share/file/magic or
/etc/magic depending on your system. But this isn't one of them. Neither
is the data UTF-8 text, or at least, the header isn't.

You could look to see if there are any snippets of readable text in it:

strings /home/pt/myday | less

But if not, then it really is just binary data, and its meaning will
depend on what program wrote it in the first place.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top