Write ESPAÑA

Asked by Rafael

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:
Last query:
Last reply:
Revision history for this message
Stephen Tiedemann (stephen-tiedemann) said :
#1

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

Revision history for this message
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()

Revision history for this message
Best Stephen Tiedemann (stephen-tiedemann) said :
#3

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

Revision history for this message
Rafael (hibara94) said :
#4

Thanks Stephen Tiedemann, that solved my question.