■ 텍스트 인코딩 파일별 바이트 순서 표시(BOM, Byte Order Mark)를 구하는 방법을 보여준다.
▶ 예제 코드 (PY)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
import codecs print("BOM :", codecs.BOM ) print("BOM_BE :", codecs.BOM_BE ) print("BOM_LE :", codecs.BOM_LE ) print("BOM32_BE :", codecs.BOM32_BE ) print("BOM32_LE :", codecs.BOM32_LE ) print("BOM64_LE :", codecs.BOM64_LE ) print("BOM64_LE :", codecs.BOM64_LE ) print("BOM_UTF8 :", codecs.BOM_UTF8 ) print("BOM_UTF16 :", codecs.BOM_UTF16 ) print("BOM_UTF16_BE :", codecs.BOM_UTF16_BE) print("BOM_UTF16_LE :", codecs.BOM_UTF16_LE) print("BOM_UTF32 :", codecs.BOM_UTF32 ) print("BOM_UTF32_BE :", codecs.BOM_UTF32_BE) print("BOM_UTF32_LE :", codecs.BOM_UTF32_LE) """ BOM : b'\xff\xfe' BOM_BE : b'\xfe\xff' BOM_LE : b'\xff\xfe' BOM32_BE : b'\xfe\xff' BOM32_LE : b'\xff\xfe' BOM64_LE : b'\xff\xfe\x00\x00' BOM64_LE : b'\xff\xfe\x00\x00' BOM_UTF8 : b'\xef\xbb\xbf' BOM_UTF16 : b'\xff\xfe' BOM_UTF16_BE : b'\xfe\xff' BOM_UTF16_LE : b'\xff\xfe' BOM_UTF32 : b'\xff\xfe\x00\x00' BOM_UTF32_BE : b'\x00\x00\xfe\xff' BOM_UTF32_LE : b'\xff\xfe\x00\x00' """ |