Activity Forums Salesforce® Discussions What is the use of isAsciiPrintable() method in Apex?

  • Anuj

    Member
    August 31, 2020 at 3:52 pm

    isAsciiPrintable()
    Returns true if the current String contains only ASCII printable characters; otherwise, returns false

  • Manish

    Member
    September 1, 2020 at 4:20 pm

    <div>isAsciiPrintable()
    Returns true if the current String contains only ASCII printable characters; otherwise, returns false
    </div>

  • Masahiro

    Member
    November 8, 2021 at 6:55 am

    @shwetak717gmail-com For more pragmatic way how to use this isAsciiPrintable aside from its simple definition when to return true or when to return false, I usually use this method for judging CJK. (Chinese, Japanese, Korean) and then trim the text field and its content within the length to fit in the same field with alpha-numeric-space-only content.ie) Case.Subject
    "Print PDF and notify the customer" (length = 33) <= English
    "PDF印刷 顧客に通知" (length = 11) <= Japanese
    These 2 phrases are saying the same meaning, but the Japanese is a lot shorter than English. So I usually vary the length to cut the text characters to fit into the space based on isAsciiPrintable only or not.
    And one more thing about CJK when we describe the name with local characters (not alphabet), Last name comes first. So the name order either LastName FirstName or FirstName (MiddleName) LastName can be determined by isAsciiPrintable() if the name is written in local zh, ja, kr or alphabet.

    • This reply was modified 3 years, 1 month ago by  Masahiro Y.
  • Patrick

    Member
    November 15, 2021 at 4:20 pm

    Greetings,They made us a button that ran on apex class and it does not work.How to check if the Class was activated + How to see if errors were received?Plus what could be the glitch and what is the solution to fix it?

Log In to reply.

Popular Salesforce Blogs