LESSON 10 OF 52 · CHAPTER 01
Unicode Text
Text length, byte count, code points and searches
10-unicode-text.srp
bind text: string = "café 🌍";
print(text_len(text), text_bytes(text), text_codepoint(text, 5));
print(text_find(text, "🌍"), text_contains(text, "é"));
print(text_starts_with(text, "caf"), text_ends_with(text, "🌍"));
stdout
6 10 127757
5 true
true true
Write what you expect this program to print. Check prediction for a line-level hint without revealing the answer, or reveal the verified output when ready. This checks displayed text only; it does not run Scarp or save your input.
UNDERSTAND THE CODE
Explanation & practice
What this example teaches
Text length, byte count, code points and searches
Expected behavior
6 10 127757, 5 true, true true
Practice: Read the source before looking at the output. Predict the values and their order, then use the pinned compiler to execute this lesson and compare the exact fixture. Identify which operation produces the result.
Unicode लंबाई और बाइट
text_len तथा text_bytes की संख्याएँ अलग हो सकती हैं। टेक्स्ट खोजने और अक्षर का कोड पॉइंट पढ़ने वाली सुविधाएँ भी दिखाई गई हैं।
अभ्यास: café 🌍 में अक्षरों और UTF-8 बाइट की गिनती क्यों अलग है?
Explanations are sourced from the project's English chapter guide and हिन्दी अध्याय. The Scarp program and output are unchanged.
LEARNING PROGRESS
Keep your place
Mark this lesson complete when you are ready.
Only saved in this browser. No account or tracking.
TRY IT LOCALLY
Verify, then execute
Use the pinned compiler from the course root. Keep any imported _support files next to the source.
scarp verify examples/01-basics/10-unicode-text.srp
scarp exec examples/01-basics/10-unicode-text.srpThe website does not run code. Read the CLI guide ↗
Pinned compiler: Scarp v0.0.6-alpha.3
· ceff07d9014f. No simulated output.