Write ESPAÑA

Asked by Rafael on 2016-10-10

Hi,
As I can do to write for example Txt Record, accents or ñ ?? For example I want to write "españa" and gives I get error by ñ.
Thank you.

Question information

Language:
English Edit question
Status:
Solved
For:
nfcpy Edit question
Assignee:
No assignee Edit question
Solved by:
Stephen Tiedemann
Solved:
2016-10-27
Last query:
2016-10-27
Last reply:
2016-10-20

Can you provide more info about the surrounding context. Unicode handling in general has many traps.

Rafael (hibara94) said : #2

This is my program:

import nfc

def connected(tag):
    record = nfc.ndef.TextRecord(text="España", language="es", encoding="UTF-8")
    new_ndef_message = nfc.ndef.Message(record)
    tag.ndef.message = new_ndef_message

clf = nfc.ContactlessFrontend("usb")
clf.connect(rdwr={"on-connect": connected})
clf.close()

The string literal "España" must be given as Unicode -> u"España"

Rafael (hibara94) said : #4

Thanks Stephen Tiedemann, that solved my question.