0

I would like to insert some special ASCII characters that I only know how to express as numbers. In Python I would for example be able to write the SYN control character as \x16 since 0x16 is SYN in ASCII. Can I do this in LIGO? I would also like to write \x0a (newline) as \n.

The official documentation for LIGO does not mention escape characters

1

Yes, you can, using exactly the same syntax. For instance, in CameLIGO, you could write let x = Bytes.pack "toto\n\x53woo".

| improve this answer | |
  • Thanks! That's very useful, does any documentation about this exist? Perhaps it could be added to the official LIGO documentation I linked to above? – Thorkil Værge Sep 23 at 21:06
  • I don't think this answer is correct. I expect an output of 0a from this call (since the ASCII value of newline is 0x0a, but I get something different. ``` $ ligo interpret -s pascaligo 'Bytes.pack("\n")' 0x0501000000025c6e ``` – Thorkil Værge Oct 16 at 14:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.