efinf:blcks2017:bitsundbytes:utf8

This is an old revision of the document!


Vervollständigen Sie folgenden Code:

utf8html.py
def to_utf8(n):
    # hier die UTF8-Byte-Sequenz als String generieren
 
def header():
    return '<!DOCTYPE html><html><head><meta charset="UTF-8"/></head><body>'
 
def footer():
    return '</body></html>'
 
def shownice(code, title=""):
    utf8 = to_utf8(code);
    res = utf8+" &nbsp; &nbsp; "+ title+" <b>Unicode</b> "+str(code)+" = "+hex(code)+ " = "+bin(code)+"  &nbsp; <b>UTF8-Codierung</b>: "
    for i in range(len(utf8)):
        res += str(ord(utf8[i])) + "  "
    res += " <b>hex</b>: "
    for i in range(len(utf8)):
        res += hex(ord(utf8[i])) + "  "
    res += " <b>binary</b>: "
    for i in range(len(utf8)):
        res += bin(ord(utf8[i])) + "  "
    return res
 
 
out = open("uft8test.html","w")
out.write(header())
out.write(shownice(0x260e,"Telefon"))
out.write(footer())
out.close()
  • efinf/blcks2017/bitsundbytes/utf8.1511254572.txt.gz
  • Last modified: 2017/11/21 09:56
  • by Ivo Blöchliger