How to remove formatting characters amid text body of news when retrieving real time news data using

Hi, one customer called me to ask the question. How to remove those invisible formatting characters amid those printable text words? Because sometimes the re-organized news story body looks like mess because of those special formatting characters. How to typeset those news body text words in order?

Best Answer

  • Hi @Liheng.Wang,

    Can you elaborate what you mean by "invisible formatting characters"? The story body text can be determined by the mimeType defined within the JSON data structure - plain text.

    image

    Stories do contain <CR><LF> (Carriage Return/Line feeds) which is used for display terminals. In addition, stories can be nativly represented in other language variants. Can you also elaborate what "typeset those news body text words in order"? You mean you want to filter out certain ASCII characters like <CR> <TAB> <LF>, etc? If so, you will need to parse the body of the text and apply your own filtering.

Answers

  • nick.zincone.1, thank you so much for answer. Yes, that is what I exactly mean. The customer said those ASCII characters are not good enough to phrase the news body and sometimes it will make the news looking like a mess. So they want to remove all this characters and then re-construct them by its own based on the plain text. So the answer is, how to identify all these characters and filter out all of them? I believe the problem they have is about how to make the news body a purely plain text.

  • Hello @Liheng.Wang
    Those control characters are generated from MRN data feed, not from the API or TREP. They are part of news story content and the API just sends it to the client application "as is". If the client wants to remove those ascii characters, the client needs to implement their own filter to detect and remove them in the application level.