Answers.Body: <p>Right-justify text in a monospaced font. If you give the input as a long string, this requires searching for spaces, breaking into substrings, and then inserting more spaces.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-09T11:43:11.803Z
Answers.LastActivityDate: 2022-09-09T11:43:11.803Z
Answers.UserDisplayName: Victor Eijkhout
Answers.Body: <p>Based on the question and follow-up comments, there appears to be uncertainty in your goals and student learning outcomes. If you clarify those goals, then it should be pretty apparent which string topics to cover.</p>
  <p>Keep in mind that strings (or any other data structure, primitive data type, algorithm domain or just about anything else in computers) have no inherent value to anyone, especially students. They're a means to achieving other ends. The rule of thumb is to start with the goal, then teach only whatever is necessary for students to achieve that goal.</p>
  <p>Perhaps your goals are to teach algorithms to improve critical thinking, prepare students for a CS degree in college and prepare them for job interviews (if job interviews still give Leetcode-style questions by the time they're entering the workforce). If so, determine their experience level and pick problems of an appropriate difficulty. Few high school students I know of are interested in or at a level where KMP or Sedgewick would be appropriate.</p>
  <p>At a beginning level, students should be able to index, iterate, concat, split, join, slice, search, adjust case and be comfortable working with common string library functions in their language. Students in an algorithms-focused course can then reimplement these library functions from first principles. Then consider functions that build on top of these primitive operations such as palindrome and isogram detectors and command line projects like <a href="https://en.wikipedia.org/wiki/Mad_Libs" rel="nofollow noreferrer">Mad Libs</a>, <a href="https://en.wikipedia.org/wiki/Hangman_(game)" rel="nofollow noreferrer">Hangman</a> <sup>(possibly no longer a politically viable name)</sup> and <a href="https://en.wikipedia.org/wiki/Wordle" rel="nofollow noreferrer">Wordle</a>.</p>
  <p>Keep in mind arrays and strings are pretty similar as sequences of characters, so you may wish to emphasize this and teach the two concepts more or less as one, especially if you're working with C.</p>
  <p>Now, if your goal is student engagement with less of an interest in college prep, consider games, animations, creative coding and web apps. Here, teach strings on a purely pragmatic, as-needed basis rather than on an &quot;every programmer should know&quot; basis (paraphrasing Spolsky's quote which really refers to professional programmers in the early 2000s, not hobbyists or students). Algorithms are important, but if you're working in a high-level language and focused on high-level goals, they're a black box students can simply invoke.</p>
  <p>Regex is probably too much, but if validation comes up in the process of making an app, I'll give students a simple regex pattern and explain the basics, like <code>\d</code>, <code>.</code>, <code>?</code>, <code>+</code> and <code>*</code>. I know professional programmers who don't touch regex, so it seems safe to file away. For the CS prep folks, a bit of exposure to the concept is fine in high school, but that's about it. I don't recall using regex at all in graduate CS even though I'm the sort of person who'd be looking for opportunities to use it.</p>
  <p>Unicode is a dry, messy industry/&quot;real world&quot; problem that doesn't need to be discussed much in high school. It's better to hide the <a href="https://suricrasia.online/iceberg/" rel="nofollow noreferrer">ugly, dumpster fire side of programming</a> for a bit. Unicode is a topic that regularly brings full-grown adult programmers with years of experience to tears<sup><em>1</em></sup>. Students will have enough frustrations to keep them busy working within a well-scoped sandbox. Expand the bounds over time, try to avoid unnecessary contrivances and acknowledge when you are simplifying things, but try to keep the rails on the crib. Like dumping all of your problems and dark secrets on the first date, showing too much mess up front scares most people off.</p>
  <p>I believe you're coming from a country and language where Unicode is a large part of everyday life. I live in the USA where we can pretty safely stuff Unicode under the table during high school and pretend it doesn't exist. Then when students enter the workforce, show them the mess, bait-and-switch style. By then, it's too late and they have to deal with uber-frustrating Unicode problems nobody else wants to touch so they can pay off their debt.</p>
  <p>If you accept the terms and conditions and really want to go into Unicode, maybe an image-to-unicode converter or command-line interface that uses <a href="https://en.wikipedia.org/wiki/Box-drawing_character" rel="nofollow noreferrer">box-drawing characters</a> would be exciting. You could maybe sneak some vegetables into the pizza if there are any pressing lessons you want students to learn. Emojis are another thing that seems fun and elegant until you try to use them in a real app and encounter the edge cases, but they can be OK for education<sup><em>2</em></sup>.</p>
  <p><sup><em>1. See <a href="https://github.com/minimaxir/big-list-of-naughty-strings/tree/db33ec7b1d5d9616a88c76394b7d0897bd0b97eb#why-test-naughty-strings" rel="nofollow noreferrer">this animation of Twitter giving an internal server error when tweeting a zero-width Unicode character</a>.</em></sup></p>
  <p><sup><em>2. As long as you're ready for them to inexplicably show up funny on Jane or Jimmy's computer and spend 3 hours trying to figure out why.</em></sup></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-09T17:53:57.157Z
Answers.Text: I wish I had my StackOverflow reputation here so I could give additional points to this answer...
Answers.UserDisplayName: Fureeish
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-09T17:59:15.507Z
Answers.Text: @Fureeish You can upvote once you have 15 rep.  You far exceed that!  Feel free to vote.
Answers.UserDisplayName: Ben I.
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-09T18:01:34.443Z
Answers.Text: @BenI. I did not refer to upvoting. I referred to awarding a bounty for an answer. I already upvoted the answer :)
Answers.UserDisplayName: Fureeish
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-10T04:10:17.100Z
Answers.Text: Thanks for the detailed answer. It gives me a lot to think about. As for the goal as I said several times I just wanted to teach them some basic string processing algorithm that every programmer should know. But I find this statement still causes quite some confusion. Maybe that is because there is no such thing in string process that everyone should know as compared to array, hash table, binary search, elementary sorts which I would argue that most of us would agree that is the very basic everyone does programming should know.
Answers.UserDisplayName: Qiulang 邱朗
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-10T04:11:55.130Z
Answers.Text: Please give me some time to think your answer over before I accept it. Thanks again.
Answers.UserDisplayName: Qiulang 邱朗
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-10T04:21:03.823Z
Answers.Text: No pressure to accept at all and thanks for the response. I would be very careful with the "every programmer should know" phrase. To me, it's all about goals, and there are few universal truths. Sure, all programmers should know what strings are and how to call library functions to do basic manipulation on them, but (depending on their goals) they may not need to know this right now, in high school. Many programmers who are writing CRUD apps or UIs probably don't need to know a whole lot about how string algorithms work unless they need them for a CS degree or job interview.
Answers.UserDisplayName: ggorlen
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-10T04:27:28.140Z
Answers.Text: Rather than asking "what are the string skills every programmer should know?", why not "what are the goals of my course and which string skills will my students need to achieve these goals?"
Answers.UserDisplayName: ggorlen
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-13T06:51:39.940Z
Answers.Text: One more question do you think it is helpful to explain the immutable concept of string in many languages ? From your answer I expect your answer would be no though lol
Answers.UserDisplayName: Qiulang 邱朗
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-13T13:04:12.073Z
Answers.Text: @ggorlen "know what strings are" That's language dependent, not? And the OP was not asking about a specific language. I believe C, Fortran, Pascal use three different conventions. In particular Fortran has radically different library functions because of the way it handles strings. Your refinement of the original question nicey sidesteps such issues, btw. So don't take this as criticism.
Answers.UserDisplayName: Victor Eijkhout
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-13T14:18:48.563Z
Answers.Text: @VictorEijkhout on a high level, understanding what strings are and what they're useful for doesn't seem that language-dependent to me. Basically, all programmers should know that strings are sequences of characters that represent letters and symbols. Sure, there are language-specific details like C doesn't have a string data type so you use null-terminated character arrays and probably the standard library `str` functions. But that doesn't really change the basic concept: if I need to represent someone's name or a piece of text, I should know to use a string.
Answers.UserDisplayName: ggorlen
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-09T16:37:31.577Z
Answers.LastActivityDate: 2022-09-13T00:45:49.787Z
Answers.LastEditDate: 2022-09-13T00:45:49.787Z
Answers.UserDisplayName: ggorlen
Answers.Body: <p>A few ideas:</p>
  <p>You can use bitwise operations to have students change text from <code>lowercase</code> to <code>CAPS</code> and back.  It's a pretty neat illustration of some of the cleverness that went into the original ASCII table.</p>
  <p>You could have them try to convert an int to a string manually, and back.</p>
  <p>You could have them create a standard, four-function calculator.  I once gave this lab as a way to teach students how to do GUIs in Java, but I quickly discovered that what I had actually given was a String processing lab, because that was where the students had all of their challenges.</p>
  <p>There is a lot of processing around the string in the screen.  What happens on the screen, for instance, as you type the sequence <code>0 0 0 - 1 0 = . . 0 0 5 . =</code>?  You would want to provide a pre-coded interface that already has pressable buttons, and enough demonstration code to show how to get a button to change what's on the screen and the current &quot;remembered&quot; number.  (The On/Off button is a good one to implement in advance as model code.)</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-13T06:13:48.207Z
Answers.Text: I think another exercise that can go with lowercase/uppercase  is to implement `isalpha()` by themselves.  Several programming languages have builtin `isalpha()`.
Answers.UserDisplayName: Qiulang 邱朗
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-09T16:12:41.647Z
Answers.LastActivityDate: 2022-09-10T13:17:53.203Z
Answers.LastEditDate: 2022-09-10T13:17:53.203Z
Answers.UserDisplayName: Ben I.
Answers.Body: <p>In modern systems we have separated text processing into two levels.</p>
  <p>At the high-level, we deal with &quot;strings&quot;, which have an opaque underlying encoding. This is a useful place to teach things like sorting, searching, and find-replace. It could also involve regex, in some sort of lesson looking for patterns in text fragments.</p>
  <p>At the low-level, we have text-encodings, such as ASCII, UTF-8, UCS-2, etc. etc. I recommend avoiding this in any youth programming class, unless students are pushing for it, or you have a very specific text-processing task in mind. Character encodings (outside of ASCII) are very very complex, and have many dirty real world issues that are not suitable for students doing early programming education. They can learn this if they are doing advanced university research or paid programming.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-11-10T08:51:38.293Z
Answers.Text: Yes, as other answers have suggested I won't touch text-encoding, I won't touch regex either as @ggorlen suggested. So do you have specific example for  high-level string algorithm ?
Answers.UserDisplayName: Qiulang 邱朗
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-11-10T06:58:40.163Z
Answers.LastActivityDate: 2022-11-10T06:58:40.163Z
Answers.UserDisplayName: David Jeske
Body: <p>When teaching algorithm (high school) I always go with some sorting &amp; searching algorithms and believe that should be <strong>enough</strong>, or at least lay a good foundation for them.</p>
  <p>But I have come to realize that teaching algorithms for <strong>string processing</strong> may also be necessary. For starters, a) every programming languages have the standard library for string processing. b) since we are Chinese we hit the Chinese garbled characters on webpages from time to time but kids in high school normally have a hard time to understand ascii vs unicode and all kinds encoding like UTF8, UTF16. c) I do believe they will deal with string process someday just like they will deal with sorting/searching.</p>
  <p>So any advice how to teach string algorithm? Do I teach them KMP or some other substring searching algorithm? Do I teach them Regular Expressions, know what that is and how to use them? I don't have much experience in this and the only material I have now is <a href="https://algs4.cs.princeton.edu/50strings/" rel="nofollow noreferrer">https://algs4.cs.princeton.edu/50strings/</a> I feel it is quite difficult for high school kids.</p>
  <p>From the comment I got I think I should make it clear my goal. I want to teach them some very basic string algorithms, i.e. some string algorithms that I will argue very programmer should know.  Using sorting &amp; searching algorithm as comparison, there are some very basic sorting &amp; searching algorithms I think very programmer should know, elementary sorts if not Quicksort (if not Quicksort but the concept of divide and conquer),  binary search, etc.</p>
  <p>Joel Spolsky wrote an article a long time ago <a href="https://www.joelonsoftware.com/2003/10/08/the-absolute-minimum-every-software-developer-absolutely-positively-must-know-about-unicode-and-character-sets-no-excuses/" rel="nofollow noreferrer">The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets</a> &quot;if you are a programmer working in 2003 and you don’t know the basics of characters, character sets, encodings, and Unicode, and I catch you ...&quot; In 2022 now but I find the situation doesn't improve much.</p>
  <p>What are the string algorithms very programmer should know ? Or is there any of, e.g does KMP or any substring search algorithm fit this category ?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-08T06:20:25.333Z
Comments.Text: Ultimately I believe that it heavily depends on your goal. *How* did you come to a conclusion that teaching algorithms for string processing may be necessary? I can see a curriculum that heavily relies on them, but I also can see a curriculum that is completely agnostic to the fact that some algorithms can be applied for demanded text-based problems. Teaching algorithms helps with developing logical thinking, but to divide and consider them into such specific groups requires either a concrete goal or a lot of free time. Not assumptions.
Comments.UserDisplayName: Fureeish
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-08T09:50:58.663Z
Comments.Text: I said in my question, "teaching algorithms for string processing may also be necessary..." That is my goal and I had thought it was quite obvious but your comment said otherwise.
Comments.UserDisplayName: Qiulang 邱朗
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-08T09:52:50.783Z
Comments.Text: My counter argument is that what is your goal to teach "sorting & searching algorithms" or any algorithm then?
Comments.UserDisplayName: Qiulang 邱朗
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-08T15:15:23.307Z
Comments.Text: @Qiulang邱朗 I think that Fureeish is getting at missing information -- you appear to be missing a goal.  "String algorithms" is too broad, especially since all that computers do really reduces to string manipulation.  What skills are you hoping they strengthen?  What do you want them to be able to do?  What do you want them to understand?  What do you wish them to learn?
Comments.UserDisplayName: Ben I.
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-08T15:24:31.177Z
Comments.Text: I agree "String algorithms" is too broad, so  what is the very basic (and this is actually my question I should make it clear)? Using sorting & searching as comparison, there are some very basic  sorting & searching algorithm I think very programmer should know. So what are the string algorithms very programmer should know ? Or is there any ?
Comments.UserDisplayName: Qiulang 邱朗
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-08T15:31:12.633Z
Comments.Text: Please check my updated question.
Comments.UserDisplayName: Qiulang 邱朗
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-08T15:39:46.737Z
Comments.Text: I keep getting the impression that you wish to teach them String-based algorithms because "why not; they haven't been taught that yet". In such case I would stick to KMP + Boyer-Moore and, if you have *a lot* of time to allocate, to some basic regex. It's a nice distinction to learn both the ins and outs of a basic searching algorithms and a practical tool like regex. I wouls suggest, however, to not delve into the details of greedy or not greedy quantifiers or of state machines.
Comments.UserDisplayName: Fureeish
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-09T02:03:05.023Z
Comments.Text: @Fureeish as I already asked you "what is your goal to teach sorting & searching algorithms or any algorithm then? Or do you teach that at all ?
Comments.UserDisplayName: Qiulang 邱朗
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-09T02:07:52.263Z
Comments.Text: @ggorlen they are high school kids. The goal is not to prepare them for jobs but to whet their interests and help them think whether they would like to study CS in university.
Comments.UserDisplayName: Qiulang 邱朗
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-09T02:37:08.560Z
Comments.Text: @Qiulang邱朗 thanks. What topics do you think would interest them? Maybe teach those.
Comments.UserDisplayName: ggorlen
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-09T03:01:24.250Z
Comments.Text: @ggorlen I don't know lol but probably most importantly is what topics they are better to know. For example Joel Spolsky wrote an article a long time ago [The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets](https://www.joelonsoftware.com/2003/10/08/the-absolute-minimum-every-software-developer-absolutely-positively-must-know-about-unicode-and-character-sets-no-excuses/) "if you are a programmer working in 2003 and you don’t know the basics of characters, character sets, encodings, and Unicode, and I catch you"
Comments.UserDisplayName: Qiulang 邱朗
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-09T03:03:54.110Z
Comments.Text: @ggorlen I labelled my question as lesson-ideas as I am collecting ideas and I am open to any suggestion.
Comments.UserDisplayName: Qiulang 邱朗
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-09T03:19:28.387Z
Comments.Text: "not prepare them for jobs but to whet their interests" and "better to know" seem somewhat at odds to me. Regardless of your goals, unicode seems likely to destroy kids' interest in programming.
Comments.UserDisplayName: ggorlen
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-09T03:24:59.893Z
Comments.Text: Probably but I don't know how often you see garbled characters on webpages. Some kids do have interest to know why. Actually I have been asked several time some even more basic question like why store number as string sometimes
Comments.UserDisplayName: Qiulang 邱朗
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-09T13:55:57.033Z
Comments.Text: @Qiulang邱朗 and I already answered that question in my original comment: "*Teaching algorithms **helps with developing logical thinking**, but to divide and consider them into such specific groups requires either a concrete goal or a lot of free time. Not assumptions.*".
Comments.UserDisplayName: Fureeish
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-09T14:49:29.293Z
Comments.Text: I agree "Teaching algorithms helps with developing logical thinking" but I also believe let them solve the practical problem (not just learning for sake of learning) is also important. That is one of reasons I am thinking about teach string process algorithm. BTW This is another try I did https://cseducators.stackexchange.com/a/7515/9884
Comments.UserDisplayName: Qiulang 邱朗
Tags: <lesson-ideas><algorithms>
Title: Teaching ideas for string algorithm?
ThreadText: # Teaching ideas for string algorithm?
  
  (Asked by: username_0 on 2022-09-08)
  
  When teaching algorithm (high school) I always go with some sorting & searching algorithms and believe that should be **enough**, or at least lay a good foundation for them.
  
  But I have come to realize that teaching algorithms for **string processing** may also be necessary. For starters, a) every programming languages have the standard library for string processing. b) since we are Chinese we hit the Chinese garbled characters on webpages from time to time but kids in high school normally have a hard time to understand ascii vs unicode and all kinds encoding like UTF8, UTF16. c) I do believe they will deal with string process someday just like they will deal with sorting/searching.
  
  So any advice how to teach string algorithm? Do I teach them KMP or some other substring searching algorithm? Do I teach them Regular Expressions, know what that is and how to use them? I don't have much experience in this and the only material I have now is <https://algs4.cs.princeton.edu/50strings/> I feel it is quite difficult for high school kids.
  
  From the comment I got I think I should make it clear my goal. I want to teach them some very basic string algorithms, i.e. some string algorithms that I will argue very programmer should know. Using sorting & searching algorithm as comparison, there are some very basic sorting & searching algorithms I think very programmer should know, elementary sorts if not Quicksort (if not Quicksort but the concept of divide and conquer), binary search, etc.
  
  Joel Spolsky wrote an article a long time ago [The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets](https://www.joelonsoftware.com/2003/10/08/the-absolute-minimum-every-software-developer-absolutely-positively-must-know-about-unicode-and-character-sets-no-excuses/) "if you are a programmer working in 2003 and you don’t know the basics of characters, character sets, encodings, and Unicode, and I catch you ..." In 2022 now but I find the situation doesn't improve much.
  
  What are the string algorithms very programmer should know ? Or is there any of, e.g does KMP or any substring search algorithm fit this category ?
  
  **Tags:** lesson-ideas, algorithms
  
  > **Comments:**
  > **username_1**: Ultimately I believe that it heavily depends on your goal. *How* did you come to a conclusion that teaching algorithms for string processing may be necessary? I can see a curriculum that heavily relies on them, but I also can see a curriculum that is completely agnostic to the fact that some algorithms can be applied for demanded text-based problems. Teaching algorithms helps with developing logical thinking, but to divide and consider them into such specific groups requires either a concrete goal or a lot of free time. Not assumptions.  
  > **username_0**: I said in my question, "teaching algorithms for string processing may also be necessary..." That is my goal and I had thought it was quite obvious but your comment said otherwise.  
  > **username_0**: My counter argument is that what is your goal to teach "sorting & searching algorithms" or any algorithm then?  
  > **username_2**: @username_0 I think that username_1 is getting at missing information -- you appear to be missing a goal.  "String algorithms" is too broad, especially since all that computers do really reduces to string manipulation.  What skills are you hoping they strengthen?  What do you want them to be able to do?  What do you want them to understand?  What do you wish them to learn?  
  > **username_0**: I agree "String algorithms" is too broad, so  what is the very basic (and this is actually my question I should make it clear)? Using sorting & searching as comparison, there are some very basic  sorting & searching algorithm I think very programmer should know. So what are the string algorithms very programmer should know ? Or is there any ?  
  > **username_0**: Please check my updated question.  
  > **username_1**: I keep getting the impression that you wish to teach them String-based algorithms because "why not; they haven't been taught that yet". In such case I would stick to KMP + Boyer-Moore and, if you have *a lot* of time to allocate, to some basic regex. It's a nice distinction to learn both the ins and outs of a basic searching algorithms and a practical tool like regex. I wouls suggest, however, to not delve into the details of greedy or not greedy quantifiers or of state machines.  
  > **username_0**: @username_1 as I already asked you "what is your goal to teach sorting & searching algorithms or any algorithm then? Or do you teach that at all ?  
  > **username_0**: @username_3 they are high school kids. The goal is not to prepare them for jobs but to whet their interests and help them think whether they would like to study CS in university.  
  > **username_3**: @username_0 thanks. What topics do you think would interest them? Maybe teach those.  
  > **username_0**: @username_3 I don't know lol but probably most importantly is what topics they are better to know. For example Joel Spolsky wrote an article a long time ago [The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets](https://www.joelonsoftware.com/2003/10/08/the-absolute-minimum-every-software-developer-absolutely-positively-must-know-about-unicode-and-character-sets-no-excuses/) "if you are a programmer working in 2003 and you don’t know the basics of characters, character sets, encodings, and Unicode, and I catch you"  
  > **username_0**: @username_3 I labelled my question as lesson-ideas as I am collecting ideas and I am open to any suggestion.  
  > **username_3**: "not prepare them for jobs but to whet their interests" and "better to know" seem somewhat at odds to me. Regardless of your goals, unicode seems likely to destroy kids' interest in programming.  
  > **username_0**: Probably but I don't know how often you see garbled characters on webpages. Some kids do have interest to know why. Actually I have been asked several time some even more basic question like why store number as string sometimes  
  > **username_1**: @username_0 and I already answered that question in my original comment: "*Teaching algorithms **helps with developing logical thinking**, but to divide and consider them into such specific groups requires either a concrete goal or a lot of free time. Not assumptions.*".  
  > **username_0**: I agree "Teaching algorithms helps with developing logical thinking" but I also believe let them solve the practical problem (not just learning for sake of learning) is also important. That is one of reasons I am thinking about teach string process algorithm. BTW This is another try I did https://cseducators.stackexchange.com/a/7515/9884  
  
  ---
  
  ## 4 answers
  
  ### Answer by username_3 on 2022-09-09. Score: 4 | Accepted answer
  
  Based on the question and follow-up comments, there appears to be uncertainty in your goals and student learning outcomes. If you clarify those goals, then it should be pretty apparent which string topics to cover.
  
  Keep in mind that strings (or any other data structure, primitive data type, algorithm domain or just about anything else in computers) have no inherent value to anyone, especially students. They're a means to achieving other ends. The rule of thumb is to start with the goal, then teach only whatever is necessary for students to achieve that goal.
  
  Perhaps your goals are to teach algorithms to improve critical thinking, prepare students for a CS degree in college and prepare them for job interviews (if job interviews still give Leetcode-style questions by the time they're entering the workforce). If so, determine their experience level and pick problems of an appropriate difficulty. Few high school students I know of are interested in or at a level where KMP or Sedgewick would be appropriate.
  
  At a beginning level, students should be able to index, iterate, concat, split, join, slice, search, adjust case and be comfortable working with common string library functions in their language. Students in an algorithms-focused course can then reimplement these library functions from first principles. Then consider functions that build on top of these primitive operations such as palindrome and isogram detectors and command line projects like [Mad Libs](https://en.wikipedia.org/wiki/Mad_Libs), [Hangman](https://en.wikipedia.org/wiki/Hangman_(game)) (possibly no longer a politically viable name) and [Wordle](https://en.wikipedia.org/wiki/Wordle).
  
  Keep in mind arrays and strings are pretty similar as sequences of characters, so you may wish to emphasize this and teach the two concepts more or less as one, especially if you're working with C.
  
  Now, if your goal is student engagement with less of an interest in college prep, consider games, animations, creative coding and web apps. Here, teach strings on a purely pragmatic, as-needed basis rather than on an "every programmer should know" basis (paraphrasing Spolsky's quote which really refers to professional programmers in the early 2000s, not hobbyists or students). Algorithms are important, but if you're working in a high-level language and focused on high-level goals, they're a black box students can simply invoke.
  
  Regex is probably too much, but if validation comes up in the process of making an app, I'll give students a simple regex pattern and explain the basics, like `\d`, `.`, `?`, `+` and `*`. I know professional programmers who don't touch regex, so it seems safe to file away. For the CS prep folks, a bit of exposure to the concept is fine in high school, but that's about it. I don't recall using regex at all in graduate CS even though I'm the sort of person who'd be looking for opportunities to use it.
  
  Unicode is a dry, messy industry/"real world" problem that doesn't need to be discussed much in high school. It's better to hide the [ugly, dumpster fire side of programming](https://suricrasia.online/iceberg/) for a bit. Unicode is a topic that regularly brings full-grown adult programmers with years of experience to tears*1*. Students will have enough frustrations to keep them busy working within a well-scoped sandbox. Expand the bounds over time, try to avoid unnecessary contrivances and acknowledge when you are simplifying things, but try to keep the rails on the crib. Like dumping all of your problems and dark secrets on the first date, showing too much mess up front scares most people off.
  
  I believe you're coming from a country and language where Unicode is a large part of everyday life. I live in the USA where we can pretty safely stuff Unicode under the table during high school and pretend it doesn't exist. Then when students enter the workforce, show them the mess, bait-and-switch style. By then, it's too late and they have to deal with uber-frustrating Unicode problems nobody else wants to touch so they can pay off their debt.
  
  If you accept the terms and conditions and really want to go into Unicode, maybe an image-to-unicode converter or command-line interface that uses [box-drawing characters](https://en.wikipedia.org/wiki/Box-drawing_character) would be exciting. You could maybe sneak some vegetables into the pizza if there are any pressing lessons you want students to learn. Emojis are another thing that seems fun and elegant until you try to use them in a real app and encounter the edge cases, but they can be OK for education*2*.
  
  *1. See [this animation of Twitter giving an internal server error when tweeting a zero-width Unicode character](https://github.com/minimaxir/big-list-of-naughty-strings/tree/db33ec7b1d5d9616a88c76394b7d0897bd0b97eb#why-test-naughty-strings).*
  
  *2. As long as you're ready for them to inexplicably show up funny on Jane or Jimmy's computer and spend 3 hours trying to figure out why.*
  
  > **Comments:**
  > **username_1**: I wish I had my StackOverflow reputation here so I could give additional points to this answer...  
  > **username_2**: @username_1 You can upvote once you have 15 rep.  You far exceed that!  Feel free to vote.  
  > **username_1**: @BenI. I did not refer to upvoting. I referred to awarding a bounty for an answer. I already upvoted the answer :)  
  > **username_0**: Thanks for the detailed answer. It gives me a lot to think about. As for the goal as I said several times I just wanted to teach them some basic string processing algorithm that every programmer should know. But I find this statement still causes quite some confusion. Maybe that is because there is no such thing in string process that everyone should know as compared to array, hash table, binary search, elementary sorts which I would argue that most of us would agree that is the very basic everyone does programming should know.  
  > **username_0**: Please give me some time to think your answer over before I accept it. Thanks again.  
  > **username_3**: No pressure to accept at all and thanks for the response. I would be very careful with the "every programmer should know" phrase. To me, it's all about goals, and there are few universal truths. Sure, all programmers should know what strings are and how to call library functions to do basic manipulation on them, but (depending on their goals) they may not need to know this right now, in high school. Many programmers who are writing CRUD apps or UIs probably don't need to know a whole lot about how string algorithms work unless they need them for a CS degree or job interview.  
  > **username_3**: Rather than asking "what are the string skills every programmer should know?", why not "what are the goals of my course and which string skills will my students need to achieve these goals?"  
  > **username_0**: One more question do you think it is helpful to explain the immutable concept of string in many languages ? From your answer I expect your answer would be no though lol  
  > **username_4**: @username_3 "know what strings are" That's language dependent, not? And the OP was not asking about a specific language. I believe C, Fortran, Pascal use three different conventions. In particular Fortran has radically different library functions because of the way it handles strings. Your refinement of the original question nicey sidesteps such issues, btw. So don't take this as criticism.  
  > **username_3**: @username_4 on a high level, understanding what strings are and what they're useful for doesn't seem that language-dependent to me. Basically, all programmers should know that strings are sequences of characters that represent letters and symbols. Sure, there are language-specific details like C doesn't have a string data type so you use null-terminated character arrays and probably the standard library `str` functions. But that doesn't really change the basic concept: if I need to represent someone's name or a piece of text, I should know to use a string.  
  
  ---
  
  ### Answer by username_2 on 2022-09-09. Score: 3
  
  A few ideas:
  
  You can use bitwise operations to have students change text from `lowercase` to `CAPS` and back. It's a pretty neat illustration of some of the cleverness that went into the original ASCII table.
  
  You could have them try to convert an int to a string manually, and back.
  
  You could have them create a standard, four-function calculator. I once gave this lab as a way to teach students how to do GUIs in Java, but I quickly discovered that what I had actually given was a String processing lab, because that was where the students had all of their challenges.
  
  There is a lot of processing around the string in the screen. What happens on the screen, for instance, as you type the sequence `0 0 0 - 1 0 = . . 0 0 5 . =`? You would want to provide a pre-coded interface that already has pressable buttons, and enough demonstration code to show how to get a button to change what's on the screen and the current "remembered" number. (The On/Off button is a good one to implement in advance as model code.)
  
  > **Comments:**
  > **username_0**: I think another exercise that can go with lowercase/uppercase  is to implement `isalpha()` by themselves.  Several programming languages have builtin `isalpha()`.  
  
  ---
  
  ### Answer by username_5 on 2022-11-10. Score: 2
  
  In modern systems we have separated text processing into two levels.
  
  At the high-level, we deal with "strings", which have an opaque underlying encoding. This is a useful place to teach things like sorting, searching, and find-replace. It could also involve regex, in some sort of lesson looking for patterns in text fragments.
  
  At the low-level, we have text-encodings, such as ASCII, UTF-8, UCS-2, etc. etc. I recommend avoiding this in any youth programming class, unless students are pushing for it, or you have a very specific text-processing task in mind. Character encodings (outside of ASCII) are very very complex, and have many dirty real world issues that are not suitable for students doing early programming education. They can learn this if they are doing advanced university research or paid programming.
  
  > **Comments:**
  > **username_0**: Yes, as other answers have suggested I won't touch text-encoding, I won't touch regex either as @username_3 suggested. So do you have specific example for  high-level string algorithm ?  
  
  ---
  
  ### Answer by username_4 on 2022-09-09. Score: 1
  
  Right-justify text in a monospaced font. If you give the input as a long string, this requires searching for spaces, breaking into substrings, and then inserting more spaces.
  
  
  ---
  
  