Skip to content

Instantly share code, notes, and snippets.

@adriannier
Last active February 7, 2021 11:54
Show Gist options
  • Save adriannier/ffda2b0aa2858cf3a759d168f055da1d to your computer and use it in GitHub Desktop.
Save adriannier/ffda2b0aa2858cf3a759d168f055da1d to your computer and use it in GitHub Desktop.
/*
# CRLF is converted to composite Unicode character
## Description
FileMaker Pro combines the character sequence CRLF into a
composite character with the Unicode decimal code point
1000013 which is in the private use area and therefore
non-standard. This behavior results in the string in
question being shorter than expected.
## Steps to reproduce
Copy and paste the calculation after this comment block as
an expression into the Data Viewer.
## Actual result
Text 1 length: 3
Text 1 codes: 10 / 13 / 32
Text 2 length: 2
Text 2 codes: 1000013 / 32
## Expected result
Text 1 length: 3
Text 1 codes: 10 / 13 / 32
Text 2 length: 3
Text 2 codes: 13 / 10 / 32
*/
Let (
[
// Compose string consisting of: Line feed, carriage return, space
text1 = Char ( 10 ) & Char ( 13 ) & Char ( 32 ) ;
text1Length = Length ( text1 ) ;
text1Codes = While (
[ buffer = "" ; i = 1 ] ;
i ≤ Length ( text1 ) ;
[
buffer = If ( not isempty ( buffer ) ; buffer & " / " ) & Code ( Middle ( text1 ; i ; 1 ) ) ;
i = i + 1
] ;
buffer
) ;
// Compose string consisting of: Carriage return, line feed, space
text2 = Char ( 13 ) & Char ( 10 ) & Char ( 32 ) ;
text2Length = Length ( text2 ) ;
text2Codes = While (
[ buffer = "" ; i = 1 ] ;
i ≤ Length ( text2 ) ;
[
buffer = If ( not isempty ( buffer ) ; buffer & " / " ) & Code ( Middle ( text2 ; i ; 1 ) ) ;
i = i + 1
] ;
buffer
)
] ;
"Text 1 length: " & text1Length & "¶" &
"Text 1 codes: " & text1Codes & "¶" &
"¶" &
"Text 2 length: " & text2Length & "¶" &
"Text 2 codes: " & text2Codes
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment