2012-06-23 03:27:19 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# coding: utf-8
|
|
|
|
|
|
|
|
from cchardet import _cchardet
|
|
|
|
|
|
|
|
def detect(msg):
|
2012-07-05 03:05:11 +00:00
|
|
|
"""
|
|
|
|
Args:
|
|
|
|
msg: str
|
|
|
|
Returns:
|
|
|
|
charset: str
|
|
|
|
Warnings:
|
|
|
|
UserWarning
|
|
|
|
"""
|
2012-06-23 03:27:19 +00:00
|
|
|
return _cchardet.detect(msg)
|
2012-07-05 03:05:11 +00:00
|
|
|
|
|
|
|
def detect_with_confidence(msg):
|
|
|
|
"""
|
|
|
|
Args:
|
|
|
|
msg: str
|
|
|
|
Returns:
|
|
|
|
{
|
|
|
|
"encoding": str,
|
|
|
|
"confidence": float
|
|
|
|
}
|
|
|
|
Warnings:
|
|
|
|
UserWarning
|
|
|
|
"""
|
|
|
|
return _cchardet.detect_with_confidence(msg)
|