File: utf8.py

package info (click to toggle)
releaseforge 1.1-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,088 kB
  • ctags: 1,239
  • sloc: python: 13,801; makefile: 68; sh: 32
file content (22 lines) | stat: -rw-r--r-- 530 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from qt import *
from types import StringType


def from_utf8(utf8str):
    # for the given string in utf8 encoding, return
    # a QString instance in utf8 
    return QString.fromUtf8(utf8str)


def to_utf8(s):
    # for the given python string or QString, return a
    # python str that is utf-8 encoded
    if type(s) is StringType:
        # python string
        u = unicode(s, 'utf-8')
    else:
        # QString 
        u = unicode(s)
    #print "type u: ", type(u.encode('utf-8'))
    return u.encode('utf-8')