web stats
preprocessor to remove hex character - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 11-02-2016, 12:18 PM
cschneidermedhost cschneidermedhost is offline
Mirth Newb
 
Join Date: Nov 2016
Posts: 13
cschneidermedhost is on a distinguished road
Default preprocessor to remove hex character

Hello, I am looking for a simple preprocessor to remove unwanted characters in a message. Some of the messages contain a hex 41 EBCDIC character known as a "no break" space or a "required space." I'm just wanting a way to either remove them or replace them with the hex code 40. For example, they are showing as this:

����MEASUREMENT��������


I've seen some message.replace scripts such as this:

Code:
message=message.replace(/\\E/g,"");

return message;
But not sure what the syntax is of what I am seeing.
Reply With Quote
  #2  
Old 11-03-2016, 06:11 AM
appsbyaaron's Avatar
appsbyaaron appsbyaaron is offline
Mirth Guru
 
Join Date: Nov 2011
Location: Florida, USA
Posts: 377
appsbyaaron is on a distinguished road
Default

If you're not familiar with regular expressions then go here: http://www.w3schools.com/jsref/jsref_obj_regexp.asp

Some helps I found:
http://stackoverflow.com/questions/4...ial-characters

http://stackoverflow.com/questions/1...-string-in-php

http://stackoverflow.com/questions/1...xadecimal-code
Reply With Quote
  #3  
Old 11-03-2016, 12:00 PM
cschneidermedhost cschneidermedhost is offline
Mirth Newb
 
Join Date: Nov 2016
Posts: 13
cschneidermedhost is on a distinguished road
Default

I appreciate the assistance, the links did help me understand this a bit more but I couldn't get any of the things I tried to work, too many unknowns like what the original encoding was, etc. I think we're going to approach it from a different perspective. Thank you
Reply With Quote
  #4  
Old 11-14-2016, 06:20 AM
AlexNeiva AlexNeiva is offline
Mirth Guru
 
Join Date: Oct 2013
Location: Portugal
Posts: 277
AlexNeiva is on a distinguished road
Default

Hi,

the variable "message" is used only on the Global Scripts and you cannot used it in the Channels Trasnformers or Filters.
Put that replacement script in the Preprocessor Scripts (Channels->GlobalScripts->Preprocessor)

Best Regards
Reply With Quote
  #5  
Old 01-24-2017, 08:19 AM
cschneidermedhost cschneidermedhost is offline
Mirth Newb
 
Join Date: Nov 2016
Posts: 13
cschneidermedhost is on a distinguished road
Default

late reply, just wanted to thank you for the help. I think my problem was not accounting for the encoding type in the channel, this site helped me in getting the right character: http://www.fileformat.info/
Reply With Quote
  #6  
Old 06-21-2019, 06:53 AM
priyap priyap is offline
What's HL7?
 
Join Date: Jun 2019
Posts: 1
priyap is on a distinguished road
Default

Quote:
Originally Posted by cschneidermedhost View Post
Hello, I am looking for a simple preprocessor to remove unwanted characters in a message. Some of the messages contain a hex 41 EBCDIC character known as a "no break" space or a "required space." I'm just wanting a way to either remove them or replace them with the hex code 40. For example, they are showing as this:

����MEASUREMENT��������


I've seen some message.replace scripts such as this:

Code:
message=message.replace(/\\E/g,"");

return message;
But not sure what the syntax is of what I am seeing.


The below code should work.

message=message.replace(/[^ -~]+/g, "");

return message;
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 12:45 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation