crs4 / hl7apy

Python library to parse, create and handle HL7 v2 messages.
http://crs4.github.io/hl7apy/
MIT License
231 stars 92 forks source link

Encoding problem assigning a unicode string with non ASCII characters to a message field #7

Open asulis opened 10 years ago

asulis commented 10 years ago

Description

An exception is raised if a unicode string is assigned to a message field, when the string contains non-ascii characters and the validation is STRICT

How to reproduce

Create a pid segment and try to assign to PID.5.1 field (surname) the following string:

pid = Segment('PID', validation_level = VALIDATION_LEVEL.STRICT)
pid.pid_5.pid_5_1 = u'mandà'

What happens

It raises

'ascii' codec can't encode character u'\xc0' in position 2: ordinal not in range(128)

What should happen

The assignment should be valid