My Tech Life

Memo by a Japanese Software Developer in his late 50s.

Entries from 2024-03-03 to 1 day

english post: 'cp932' codec can't encode character '\x##' in position ####: illegal multibyte sequence

'cp932' codec can't encode character '©' in position 3337: illegal multibyte sequence Exception commonly encountered when running Python on Japanese version of Windows, but almost never observed on Linux. Verify the point below before delv…

'cp932' codec can't encode character '\x##' in position ####: illegal multibyte sequence

'cp932' codec can't encode character '\xa9' in position 3337: illegal multibyte sequence Windowsで、Pythonを動かすとよく見る例外。Linuxだと見ない。 エンコード・デコードの深みを調査する前に、これを確認すること。 自分への備忘録。 スタックト…

reading .mbox file in python

With a tendency to forget things often, I've decided to open a blog to keep future memos. Over the past decade or so, my Gmail account has accumulated a lot of emails, mostly advertisements and newsletters. With such a large collection, I …

decoding mail headers in python

Memo on decoding the email header. Using the sender/from address as an example. from email.header import decode_header decoded = decode_header(message['from']) outstr = decoded[0][0].decode(decoded[0][1]) # sample: decoded[0][0] # b'Linked…

メールヘッダーのデコード

メールヘッダーのデコード部分の備忘録。 送信元を例に。 from email.header import decode_header decoded = decode_header(message['from']) outstr = decoded[0][0].decode(decoded[0][1]) # 例)decoded[0][0] # b'LinkedIn\xe3\x82\xb3\xe3\x83\xb3\xe3…

pythonでmboxを読む

物忘れが多く、今後の備忘録を書くためにブログを開設。 ここ10年ぐらいのメールがGmailにたまっている。 ほとんど広告やニュースレターだが、これだけたくさん溜まっていると、 時代ごとに何か面白い傾向でも見つかるかと、Pythonで分析したく思った。 Gmai…