tttwwy / pyjft Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/pyjft
Automatically exported from code.google.com/p/pyjft
您好,我修改了一下 j2f
简体转繁体的函数,基本上可以实现带有字符,逗号,英
文,数字等特殊符合和中文简体混排的内容也可以正常的转��
�成繁体字符串。 下面的
代码供您参考。
def _j2f(nc, destinationEncoding):
pos = jt.find(nc)
while pos>0:
if pos%2 == 0:
return unicode(ft[pos:pos+2],'gbk').encode(destinationEncoding)
break
pos = jt.find(nc,pos+1)
return None
def j2f(sourceEncoding,destinationEncoding,sourceString):
'''
Simplified Chinese character to traditional Chinese character converter
Parameters:
sourceEncoding : The encoding codec name of string to be converted
destinationEncoding : The encoding codec name of output string
sourceString : The string to be converted
Return value:
The output traditional Chinese character string
'''
des = []
nString = unicode(sourceString,sourceEncoding).encode('gbk')
#print nString
sLen = len(nString)
i = 0
while i < sLen:
nc = nString[i:i+2]
fnc = _j2f(nc,destinationEncoding)
if fnc:
des.append(fnc)
i += 2
else:
des.append(nString[i:i+1])
i += 1
return ''.join(des)
其他部分都不用改变。
联系人:lidongok # gmail.com
Original issue reported on code.google.com by [email protected]
on 1 Dec 2009 at 7:50
Attachments:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.