SimpleMLLPClient charachters encoding
Closed this issue · 4 comments
Unfortunately, the way the SimpleMLLPClient is written is suitable only in case of ANSI (single byte) encoding of communication. The problem is in receiving answer and no issues in sending. The method “public string SendHL7Message(string message)” takes for granted that incoming message is composed by single byte encoded characters, which IMHO is wrong. Here is the code:
sb.Append((char) b); (line 109, SimpleMLLPClient.cs)
which takes one byte and interprets it as if it is ANSI character. In case of utf-8 for example, non-ANSI characters comes wrongly encoded. I could make some changes, if help is appreciated. I think that SimpleMLLPClient should have one more property – Encoding. Basically, object should capture just bytes, and check for end of message (messageComplete = MLLP.ValidateMLLPMessage(sb);) with ad-hoc appropriate encoding (set by proposed by me new property).
Hi!
You're right. It is better to make the MLLPClient handle multiple encoding in a better way. Help is surely appreciated. You can send the changes as pull request, or I can make you a contributer to the project if you want.
I wrote the initial support for encoding in HAPI. Current state is listed here: https://sourceforge.net/p/hl7api/code/HEAD/tree/trunk/hapi-mvn/hapi-base/src/main/java/ca/uhn/hl7v2/llp/ - I'm no C# wizard so I'm probably of little help
Thanks! I'll take a look at it soon!