Carriage Return and Line Feed (CRLF)
Hi there,
In Ninox, I want to create a text file for an import into a 3rd party solution. The 3rd party solution requires line breaks to be formatted as carriage return + line feed ("CRLF").
The "standard" Ninox line break is just "LF". I tried to replace these line breaks via replace(text,"\n","\r\n") - which should work according to the support. But id doesn't. I also tried all kind of alternatives via Integromat / MAKE, but no result. It just works manually with Notepad 2.0 so far.
Has anybody an idea how I can use CRLF line breaks instead of LF line breaks? If possible without external tools (eg. Integromat / MAKE)?
Thank you!
Fabian
5 replies
-
Indeed, replace(text,"\n","\r\n") replaces \n by \\r\\n. This comes from the fact that Ninox does not allow to enter special characters, that is to say those which are not alphanumeric, in its script.
The best way is to use a URI encoding. In this case, the special characters are transformed into hexadecimal numbers with a % prefix. LF = %0A (character 10) and CR = %0D (character 13).
If you type this code in the console...var mySource := "is a standard Ninox ligne with \n = %0A"; urlEncode(mySource)
we obtain : is%20a%0Astandard%20Ninox%0Aligne%20with%20%5Cn%20%3D%20%250A.
%20 : space,
%0A : retour à la ligne,
%5C : \,
%3D : =,
%25 : %we can then easily replace %0A by %0D%0D :
replace(urlEncode(mySource),"%0A","%0D%0A"))
You can see in the result the CRLF instead of LF : is%20a%0D%0Astandard%20Ninox%0D%0Aligne%20with%20%5Cn%20%3D%20%250A
All that remains is to transform it back into Ninox text using urlDecode :
urlDecode(replace(urlEncode(mySource),"%0A","%0D%0A"))
To check the result, simply use the debugValueInfo function that allows you to see special characters
debugValueInfo(urlDecode(replace(urlEncode(mySource),"%0A","%0D%0A")))
The result will be : string("is a\r\nstandard Ninox\r\nligne with \\n = %0A")
-
You're brilliant! You cannot imagine how long and how many solutions I've thought about...
THANK YOU! -
I put here a complementary function that allows you to convert a character into a decimal (or hexadecimal) value:
function ord(t : text) do var ascii := urlDecode("%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20!%22#$%25&'()*+,-./0123456789:;%3C=%3E?@ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F%C2%80%C2%81%C2%82%C2%83%C2%84%C2%85%C2%86%C2%87%C2%88%C2%89%C2%8A%C2%8B%C2%8C%C2%8D%C2%8E%C2%8F%C2%90%C2%91%C2%92%C2%93%C2%94%C2%95%C2%96%C2%97%C2%98%C2%99%C2%9A%C2%9B%C2%9C%C2%9D%C2%9E%C2%9F%C2%A0%C2%A1%C2%A2%C2%A3%C2%A4%C2%A5%C2%A6%C2%A7%C2%A8%C2%A9%C2%AA%C2%AB%C2%AC%C2%AD%C2%AE%C2%AF%C2%B0%C2%B1%C2%B2%C2%B3%C2%B4%C2%B5%C2%B6%C2%B7%C2%B8%C2%B9%C2%BA%C2%BB%C2%BC%C2%BD%C2%BE%C2%BF%C3%80%C3%81%C3%82%C3%83%C3%84%C3%85%C3%86%C3%87%C3%88%C3%89%C3%8A%C3%8B%C3%8C%C3%8D%C3%8E%C3%8F%C3%90%C3%91%C3%92%C3%93%C3%94%C3%95%C3%96%C3%97%C3%98%C3%99%C3%9A%C3%9B%C3%9C%C3%9D%C3%9E%C3%9F%C3%A0%C3%A1%C3%A2%C3%A3%C3%A4%C3%A5%C3%A6%C3%A7%C3%A8%C3%A9%C3%AA%C3%AB%C3%AC%C3%AD%C3%AE%C3%AF%C3%B0%C3%B1%C3%B2%C3%B3%C3%B4%C3%B5%C3%B6%C3%B7%C3%B8%C3%B9%C3%BA%C3%BB%C3%BC%C3%BD%C3%BE%C3%BF"); index(ascii, substr(t, 0, 1)) end
ord("A") return 65
With the following code, you can convert a string into an array of ascii numbers:
var t := for i in "Hello friends !" do ord(i) end
t = [72,101,108,108,111,32,102,114,105,101,110,100,115,32,33]
So you can easily manipulate the value of each character, then convert it back to a string:
var m := for i in t do chr(i+1); end;
m = ["I","f","m","m","p","!","g","s","j","f","o","e","t","!","\""]
Then find the resulting string :
var c := join(m,"")
c = "Ifmmp!gsjfoet!\""
Content aside
- Status Answered
- 2 yrs agoLast active
- 5Replies
- 1839Views
-
2
Following