pykf utf8 pythonで日本語文字列をutf8に統一するためのコード

def utf8(text):
  #if unicode-type
  if isinstance(text, basestring)==True:
    text=text.encode('utf8')

  #if str-type
  c=pykf.guess(text)
  if c is pykf.UTF8:
    return text
  elif c is pykf.SJIS:
    return unicode(text,'sjis').encode('utf8')

Windows環境のコマンドプロンプトで日本語入力すると、
unicode typeかsjisになってしまい、その文字列をWebで使おうとすると
Webの標準はutf8なのでエラーになったりする。
そこで、なんでもutf8にしちゃおうというコード。