Skip to content

Commit e7b612d

Browse files
authored
1 parent a0fe6ba commit e7b612d

File tree

2 files changed

+2
-19
lines changed

2 files changed

+2
-19
lines changed

lib/hl7/message.ex

+2-11
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ defmodule HL7.Message do
1111
1212
`copy: true` -- Will create binary copies while parsing to avoid keeping references.
1313
`validate_string: true` -- Will generate an `HL7.InvalidMessage` if the source text is not UTF-8 compatible.
14-
`accept_latin1: true` -- If used with `validate_string: true`, this will take failed validations and attempt to encode any latin1 as UTF-8.
15-
If used without `validate_string: true`, this will always attempt to encode any latin1 as UTF-8.
1614
"""
1715
alias HL7.Path
1816

@@ -510,17 +508,10 @@ defmodule HL7.Message do
510508
end
511509

512510
defp validate_text(raw_text, options) do
513-
encoded_text =
514-
if options[:accept_latin1] == true do
515-
:unicode.characters_to_binary(raw_text, :latin1)
516-
else
517-
raw_text
518-
end
519-
520511
validate_string = options[:validate_string] == true
521512

522-
if !validate_string or String.valid?(encoded_text) do
523-
{:ok, encoded_text}
513+
if !validate_string or String.valid?(raw_text) do
514+
{:ok, raw_text}
524515
else
525516
%HL7.InvalidMessage{
526517
raw: raw_text,

test/hl7_message_test.exs

-8
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,6 @@ defmodule HL7MessageTest do
156156
assert %HL7.InvalidMessage{} = HL7.Message.new(latin1_msg, %{validate_string: true})
157157
end
158158

159-
test "A message with latin1 data passed into Message.new will result in a valid Message with options `validate_string: true` and `accept_latin1: true`" do
160-
latin1_text = <<220, 105, 178>>
161-
latin1_msg = HL7.Examples.wikipedia_sample_hl7() |> String.replace("A01", latin1_text)
162-
163-
assert %HL7.Message{} =
164-
HL7.Message.new(latin1_msg, %{validate_string: true, accept_latin1: true})
165-
end
166-
167159
test "An incomplete header passed into Message.new will result in InvalidMessage" do
168160
missing_message_type =
169161
HL7.Examples.wikipedia_sample_hl7() |> String.replace("ADT^A01^ADT_A01", "")

0 commit comments

Comments
 (0)