Skip to Content (Press Enter)
OutSystems.com
Personal Edition
Community
Support
Training
Training
Online Training
Developer Schools
Boot Camps
Certifications
Tech Talks
Documentation
Documentation
Overview
ODC
O11
Forums
Forge
Get Involved
Get Involved
Jobs
Ideas
Members
Mentorship
User Groups
Platform
Platform
ODC
O11
Search in OutSystems
Log in
Get Started
Back to Forums
Tiago Bernardo
Champion
372
Views
7
Comments
Is there the inverse of the Chr() built-in function?
Question
Hi!
The Chr() built-in function: "The Chr function is a built-in function that returns a single-character string corresponding to the c Ascii character code."
https://www.outsystems.com/help/ServiceStudio/9.0/Language_Reference/Built_in_Functions/Text_functions/Chr_Function.htm
Is there a built-in inverse function that I don't know of? From a character returns the ascii character code.
Guilherme Pereira
Staff
Hi Tiago,
There's no built in function for that but it should be quite easy to accomplish using c# or java (for example for c# something like
int charCode = ((int)ssMyString[0])
.
Hope this helps
Guilherme
Pramod Jain
MVP
in C# (.net) i simply use Convert.ToChar(65) and works fine.
Tiago Bernardo
Champion
Using the database SQL Server (didn't check other databases):
SELECT
ASCII
(
@Char
)
---
Miguel João
Staff
Hello Tiago,
Depending on the number of times you'll be executing that function, perhaps the query solution generates a significant overhead, as it causes a query to be executed on the database server. I'ts less performant and increases unnecessary load on the database server.
Recommend using one of the other solutions instead.
Cheers
1 reply
20 Aug 2015
Show thread
Hide thread
Tiago Bernardo
Champion
Hello Miguel,
Thank you for your note.
I do know this solution is less performant when compared to the others, but this function will be executed just a few times so it will not cause any impact.
PS: Couldn't this function just be added as a built-in function in the plataform? How hard can that be? :)
Miguel João
wrote:
Hello Tiago,
Depending on the number of times you'll be executing that function, perhaps the query solution generates a significant overhead, as it causes a query to be executed on the database server. I'ts less performant and increases unnecessary load on the database server.
Recommend using one of the other solutions instead.
Cheers
Tiago Bernardo
Champion
Created an idea:
https://www.outsystems.com/ideas/2115/add-a-built-in-function-which-is-the-inverse-of-chr
Miguel Ventura
Staff
Let me just add to this thread that while getting a character from its ASCII code is trivial, predictable and safe, since OutSystems' applications are unicode-ready, getting the ASCII code from a character you don't know beforehand may not be strictly doable because that character may well be out of the ASCII space.
Java and .NET use UTF-16 for string encoding internally and even there you may have characters such as the
unicode slice of pizza
which need to be decoced into multiple UTF-16 code points.
I believe the main use-case of the
Chr
function to be the representation of characters such as CR, LF or TAB in a clear and predictable manner, rather than other possible uses such as generating letters.
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
See the full guidelines
Loading...