From edfb9a38edeedabc83d48855be66f454f0c4048d Mon Sep 17 00:00:00 2001 From: Nenad Date: Tue, 18 Jun 2024 08:25:39 +0200 Subject: [PATCH] Create strings concept --- concepts/strings/.meta/config.json | 7 +++++++ concepts/strings/about.md | 1 + concepts/strings/introduction.md | 3 +++ concepts/strings/links.json | 14 ++++++++++++++ 4 files changed, 25 insertions(+) create mode 100644 concepts/strings/.meta/config.json create mode 100644 concepts/strings/about.md create mode 100644 concepts/strings/introduction.md create mode 100644 concepts/strings/links.json diff --git a/concepts/strings/.meta/config.json b/concepts/strings/.meta/config.json new file mode 100644 index 00000000..60942e9a --- /dev/null +++ b/concepts/strings/.meta/config.json @@ -0,0 +1,7 @@ +{ + "blurb": "ByteArray is a sequence of ASCII characters longer than 31 characters, written using double quotes", + "authors": [ + "misicnenad" + ], + "contributors": [] +} \ No newline at end of file diff --git a/concepts/strings/about.md b/concepts/strings/about.md new file mode 100644 index 00000000..2c0923c4 --- /dev/null +++ b/concepts/strings/about.md @@ -0,0 +1 @@ +# String diff --git a/concepts/strings/introduction.md b/concepts/strings/introduction.md new file mode 100644 index 00000000..d5e1124b --- /dev/null +++ b/concepts/strings/introduction.md @@ -0,0 +1,3 @@ +# Introduction + +In Cairo, there's no native type for strings. Instead, you can use a single `felt252` to store a short string of up to 31 characters, or a `ByteArray` for strings of arbitrary length. Short strings use single quotes and `ByteArray` uses double quotes. All characters must follow the ASCII standard. diff --git a/concepts/strings/links.json b/concepts/strings/links.json new file mode 100644 index 00000000..c9c1e4cc --- /dev/null +++ b/concepts/strings/links.json @@ -0,0 +1,14 @@ +[ + { + "url": "https://book.cairo-lang.org/ch02-02-data-types.html#string-types", + "description": "String types in the Cairo book" + }, + { + "url": "https://starknet-by-example.voyager.online/getting-started/basics/bytearrays-strings.html", + "description": "Starknet by Example section on Strings and ByteArrays" + }, + { + "url": "https://docs.starknet.io/architecture-and-concepts/smart-contracts/serialization-of-cairo-types/#serialization_of_byte_arrays", + "description": "Starknet docs explaining how ByteArray is implemented and how it's serialized" + } +] \ No newline at end of file