Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

102 Commits
102 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.