How can I re-add a unicode byte order marker in linux?

前端 未结 7 1904
-上瘾入骨i
-上瘾入骨i 2021-02-13 15:22

I have a rather large SQL file which starts with the byte order marker of FFFE. I have split this file using the unicode aware linux split tool into 100,000 line chunks. But whe

7条回答
  •  被撕碎了的回忆
    2021-02-13 15:24

    For a general-purpose solution—something that sets the correct byte-order mark regardless of whether the file is UTF-8, UTF-16, or UTF-32—I would use vim’s 'bomb' option:

    $ echo 'hello' > foo
    $ xxd < foo
    0000000: 6865 6c6c 6f0a                           hello.
    $ vim -e -s -c ':set bomb' -c ':wq' foo
    $ xxd < foo
    0000000: efbb bf68 656c 6c6f 0a                   ...hello.
    

    (-e means runs in ex mode instead of visual mode; -s means don’t print status messages; -c means “do this”)

提交回复
热议问题