Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

How to replace or remove any invalid characters from text

(0) ShareShare
ReportReport
Posted on by 6

Hi All,

Kindly let me know how to replace or remove any invalid characters from text in AX 2012 R3. 

When I am copied and trying to paste the invalid characters in code  it display like empty So, not able to apply in function like strRep or strRem to remove or replace that invalid characters from text.

Kindly suggest me how we can achieve this?l

Please give me more shed on this.

thanks!

  • Suggested answer
    Martin Dráb Profile Picture
    231,886 Most Valuable Professional on at
    RE: How to replace or remove any invalid characters from text

    Please be more specific. What did you try to paste and where and where is something showing blank?

    Anyway, a better idea than copy & paste may be using Unicode character codes. For example:

    str s = System.Char::ConvertFromUtf32(0x2606);

    And even a better idea may be finding it why you got such characters in the input and preventing it.

  • @rp@n Profile Picture
    6 on at
    RE: How to replace or remove any invalid characters from text

    8103.a1.jpg

    In notepad, I am getting the string like this.   kindly let me know how we can remove or replace through x++.

    please give me more shed on this.

    thanks!

  • @rp@n Profile Picture
    6 on at
    RE: How to replace or remove any invalid characters from text

    Martin, please let me know how will pass that marked character in StrReplace function?

    When i am trying to paster , its showing blank.

    Please give me more shed on this

  • Suggested answer
    Martin Dráb Profile Picture
    231,886 Most Valuable Professional on at
    RE: how to replace or remove any invalid characters from text in AX 2012 R3.

    Well, that you have the problem with these particular characters today doesn't mean that you won't run to another character tomorrow. Even the title of this thread asks "how to replace or remove any invalid characters".

    But anyway, you can use strReplace() to find and replace a character in a string. If you want to remove it, replace it with an empty string.

  • @rp@n Profile Picture
    6 on at
    RE: how to replace or remove any invalid characters from text in AX 2012 R3.

    Martin, which I marked that only cause the issue. That marked character I wants to remove.

    Kindly advice

  • Martin Dráb Profile Picture
    231,886 Most Valuable Professional on at
    RE: how to replace or remove any invalid characters from text in AX 2012 R3.

    Your screenshot shows two characters. Are you saying that you want a solution for these two characters only? I doubt so. Also, there may be some special characters that aren't actually displayed.

    I believe you need something more generic, but you haven't yet thought about your requirements. You must think about what you actually want before you can write code doing such a thing.

    You mentioned ASCII, therefore you may want to remove all characters that aren't in the ASCII table, but it's not clear whether it's safe enough. There may be non-ASCII characters that may be acceptable. Also, ASCII contains characters that aren't valid for an invoice number, such as the vertical tab. Therefore accepting all ASCII table isn't really safe, although it may be acceptable in your code. Maybe you rather want to accept selected Unicode character categories, or something like that.

  • @rp@n Profile Picture
    6 on at
    RE: how to replace or remove any invalid characters from text in AX 2012 R3.

    Martin, already I have marked in the screen shot in trail post. Kindly follow pls

  • Martin Dráb Profile Picture
    231,886 Most Valuable Professional on at
    RE: how to replace or remove any invalid characters from text in AX 2012 R3.

    Which characters do you consider invalid in your particular case?

  • @rp@n Profile Picture
    6 on at
    RE: how to replace or remove any invalid characters from text in AX 2012 R3.

    thanks ergun,

    if possible , pls send me the code sample.

  • Suggested answer
    ergun sahin Profile Picture
    8,816 Moderator on at
    RE: how to replace or remove any invalid characters from text in AX 2012 R3.

    Select the record  and set to a string valuable. Get lenght with strlen. Loop it and get every value with char2num. You can get ascii with this. Seach Ä°nternet with this value and do whatever you want at next step

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,110 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,886 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans