-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathutil_recode.py
More file actions
executable file
·32 lines (23 loc) · 990 Bytes
/
Copy pathutil_recode.py
File metadata and controls
executable file
·32 lines (23 loc) · 990 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/local/bin/python3 -bb
import ftnconfig
db=ftnconfig.connectdb()
#MIDs=db.prepare("select id from messages where source=14776")
MIDs=[(3113949,)]
for (MID,) in MIDs:
newc="utf-8"
h,b,c=db.prepare("select header, body, origcharset from messages where id=$1").first(MID)
#print(c)
#print(repr(b.encode("koi8-r")))
#print(b.encode("koi8-r").decode("utf-8", "ignore"))
#exit()
h.find("sendername").text = h.find("sendername").text.encode(c).decode(newc)
h.find("recipientname").text= h.find("recipientname").text.encode(c).decode(newc)
h.find("subject").text = h.find("subject").text.encode(c).decode(newc)
b = b.encode(c).decode(newc)
print("declared as", c)
print(h.find("sendername").text)
print(h.find("recipientname").text)
print(h.find("subject").text)
print (b)
input("Ctrl-C to cancel or Enter to update")
db.prepare("update messages set (header, body, origcharset) = ($2, $3, $4) where id=$1")(MID, h, b, newc)