Skip to content

About

Python Japanese codecs by NKF (Network Kanji Filter)

Topics

Resources

Stars

18 stars

Watchers

6 watching

Forks

Latest commit

 

History

102 Commits

Folders and files

Repository files navigation

Python Interface to NKF (Network Kanji Filter)

How to Install

Install from PyPI:

$ sudo pip install nkf

Install from source tree:

$ make
$ sudo make install

Run tests:

$ make test

Usage

## flag is same as the flags of nkf itself
import nkf
output = nkf.nkf(flag, input)

## For example, to convert from euc-jp to utf-8
output = nkf.nkf('-Ew', 'some euc-jp string')

## Options can also be passed as a list or tuple
output = nkf.nkf(['-E', '-w'], 'some euc-jp string')
output = nkf.nkf(['--ic=euc-jp', '--oc=utf-8n'], 'some euc-jp string')

## Guess character encoding
input_encoding = nkf.guess('some string')

## Guess character encoding and newline type
encoding, newline = nkf.guess_detail('some string')

guess() function guesses an input string encoding and returns one of next strings:

  • BINARY
  • ASCII
  • Shift_JIS
  • CP932
  • EUC-JP
  • EUCJP-MS
  • CP51932
  • ISO-2022-JP
  • CP50221
  • CP50220
  • UTF-8
  • UTF-16
  • UTF-32

guess_detail() function returns a tuple of (encoding, newline). encoding is same as guess(), and newline is one of:

  • None (no newline detected)
  • LF
  • CR
  • CRLF
  • MIXED

About

Python Japanese codecs by NKF (Network Kanji Filter)

Topics

Resources

Stars

18 stars

Watchers

6 watching

Forks

Releases

Packages

Used by

Contributors

Languages