Когда я пытаюсь использовать Context.write (k, v) в MapReduce (используя Java) для записи данных в файл, я нахожу следующее содержимое в файле (открывается с помощью vi, есть: set list):
В чем смысл ^@^Iи $? Имеет ли в ^Iвиду \t? Я знаю, что это $означает конец строки, но означает ли это клавишу ввода, как \n? Если так, то в чем разница между '$' и '^ M' в vi?
3 ответа на вопрос
3
romainl
$ is the end of line as displayed by :set list with the default value of the listchar option. ^I is the tab character.
^@ is the null character.
For some weird reason every meaningful character in your file is prepended with a null character except digits and (probably) spaces.
This is not a Vi(m) problem: check the documentation of that method to see if there's a way to output your data without those nulls.
1
pilona
The file that you opened is UTF-16 or UCS-2 encoded, which is the standard in Java. vi (as in real vi, not vim symlinked to vi) can only handle ASCII (or ISO-8859-1?) text. Use vim, or convert the file to ASCII (e.g., iconv -f utf-16 -t ascii <input> <output>).
0
Ingo Karkat
If that's Vim behind your vi command, you can reload the file with
:edit ++enc=ucs-2
or directly specify the encoding
$ vim ++enc=ucs-2 filename
or, if you need to open these files frequently, prepend ucs-2 to the 'fileencodings' option, e.g. in your ~/.vimrc.
Разве vim не должен автоматически определять кодировку? Или это происходит только при наличии спецификации?
pilona 10 лет назад
0
@pilona: То, что обнаруживается, контролируется опцией `'fileencodings'`, о которой я упоминал.
Ingo Karkat 10 лет назад
0