String (computer science): Difference between revisions

Content deleted Content added
No edit summary
Tags: Reverted nowiki added references removed Visual edit
m Reverted 1 edit by 49.37.137.95 (talk) to last revision by Wiiformii
Line 2:
[[File:String example.png|alt=Diagram of String data in computing. Shows the word "example" with each letter in a separate box. The word "String" is above, referring to the entire sentence. The label "Character" is below and points to an individual box.|thumb|Strings are typically made up of [[character (computing)|characters]], and are often used to store human-readable data, such as words or sentences.]]
 
In [[computer programming]], a '''string''' is traditionally a [[sequence]] of [[character (computing)|characters]], either as a [[literal (computer programming)|literal constant]] or as some kind of [[Variable (computer science)|variable]]. The latter may allow its elements to be [[Immutable object|mutated]] and the length changed, or it may be fixed (after creation). A string is generally considered as a [[data type]] and is often implemented as an [[array data structure]] of [[byte]]s (or [[word (computer architecture)|word]]s) that stores a sequence of elements, typically characters, using some [[character encoding]]. ''String'' may also denote more general [[Array data type|arrays]] or other sequence (or [[List (abstract data type)|list]]) data types and structures.
கணினி நிரலாக்கத்தில், ஒரு சரம் என்பது பாரம்பரியமாக எழுத்துகளின் வரிசையாகும், இது ஒரு நேரடி மாறிலி அல்லது ஒருவித மாறி. பிந்தையது அதன் உறுப்புகளை மாற்றியமைக்க மற்றும் நீளத்தை மாற்ற அனுமதிக்கலாம் அல்லது அது (உருவாக்கிய பிறகு) சரி செய்யப்படலாம். ஒரு சரம் பொதுவாக தரவு வகையாகக் கருதப்படுகிறது மற்றும் பெரும்பாலும் பைட்டுகளின் (அல்லது சொற்கள்) வரிசை தரவு கட்டமைப்பாக செயல்படுத்தப்படுகிறது, இது சில எழுத்துக்குறி குறியாக்கத்தைப் பயன்படுத்தி உறுப்புகளின் வரிசையை, பொதுவாக எழுத்துக்களை சேமிக்கிறது. சரம் என்பது பொதுவான வரிசைகள் அல்லது பிற வரிசை (அல்லது பட்டியல்) தரவு வகைகள் மற்றும் கட்டமைப்புகளைக் குறிக்கலாம்.
 
Depending on the programming language and precise data type used, a [[variable (programming)|variable]] declared to be a string may either cause storage in memory to be statically allocated for a predetermined maximum length or employ [[dynamic allocation]] to allow it to hold a variable number of elements.
நிரலாக்க மொழி மற்றும் பயன்படுத்தப்படும் துல்லியமான தரவு வகையைப் பொறுத்து, ஒரு சரம் என அறிவிக்கப்பட்ட மாறியானது நினைவகத்தில் சேமிப்பை முன்னரே தீர்மானிக்கப்பட்ட அதிகபட்ச நீளத்திற்கு நிலையான முறையில் ஒதுக்கலாம் அல்லது மாறி எண்ணிக்கையிலான உறுப்புகளை வைத்திருக்க அனுமதிக்க டைனமிக் ஒதுக்கீட்டைப் பயன்படுத்தலாம்.
 
When a string appears literally in [[source code]], it is known as a [[string literal]] or an anonymous string.<ref>{{cite web|url=http://www.acsu.buffalo.edu/~fineberg/mfc158/week10lecture.htm|title=Introduction To Java – MFC 158 G|quote=String literals (or constants) are called ‘anonymous strings’|url-status=live|archive-url=https://web.archive.org/web/20160303233357/http://www.acsu.buffalo.edu/~fineberg/mfc158/week10lecture.htm|archive-date=2016-03-03}}</ref>
மூலக் குறியீட்டில் ஒரு சரம் உண்மையில் தோன்றும்போது, ​​அது ஒரு சரம் அல்லது அநாமதேய சரம் என அறியப்படுகிறது.
 
In [[formal language]]s, which are used in [[mathematical logic]] and [[theoretical computer science]], a string is a finite sequence of [[symbol (formal)|symbol]]s that are chosen from a [[set (mathematics)|set]] called an [[alphabet (computer science)|alphabet]].
கணித தர்க்கம் மற்றும் தத்துவார்த்த கணினி அறிவியலில் பயன்படுத்தப்படும் முறையான மொழிகளில், ஒரு சரம் என்பது எழுத்துக்கள் எனப்படும் தொகுப்பிலிருந்து தேர்ந்தெடுக்கப்பட்ட குறியீடுகளின் வரையறுக்கப்பட்ட வரிசையாகும்.
 
== Purpose ==
நோக்கம்
 
A primary purpose of strings is to store human-readable text, like words and sentences. Strings are used to communicate information from a computer program to the user of the program.<ref>{{cite web |url=https://users.cs.utah.edu/~germain/PPS/Topics/strings.html |website=University of Utah, Kahlert School of Computing |title=Strings
வார்த்தைகள் மற்றும் வாக்கியங்கள் போன்ற மனிதர்கள் படிக்கக்கூடிய உரையை சேமிப்பதே சரங்களின் முதன்மை நோக்கம். கம்ப்யூட்டர் புரோகிராமில் இருந்து அந்த நிரலின் பயனருக்குத் தகவல் தெரிவிக்க சரங்கள் பயன்படுத்தப்படுகின்றன. ஒரு நிரல் அதன் பயனரிடமிருந்து சரம் உள்ளீட்டையும் ஏற்கலாம். மேலும், சரங்கள் எழுத்துகளாக வெளிப்படுத்தப்பட்ட தரவைச் சேமிக்கலாம், ஆனால் மனித வாசிப்புக்கு நோக்கம் இல்லை.
|first=H. James |last=de St. Germain }}</ref> A program may also accept string input from its user. Further, strings may store data expressed as characters yet not intended for human reading.
 
Example strings and their purposes:
எடுத்துக்காட்டு சரங்கள் மற்றும் அவற்றின் நோக்கங்கள்:
 
* A message like "<code>file upload complete</code>" is a string that software shows to [[end user]]s. In the program's [[source code]], this message would likely appear as a [[string literal]].
"கோப்பு பதிவேற்றம் முடிந்தது" போன்ற செய்தியானது இறுதிப் பயனர்களுக்கு மென்பொருள் காட்டும் சரமாகும். நிரலின் மூலக் குறியீட்டில், இந்தச் செய்தி ஒரு சரமாகத் தோன்றும்.
* User-entered text, like "<code>I got a new job today</code>" as a status update on a [[social media]] service. Instead of a string literal, the software would likely store this string in a [[database]].
* Alphabetical data, like "<code>AGATGCCGT</code>" representing nucleic acid sequences of [[DNA]].<ref>{{cite web |url=https://plant-breeding-genomics.extension.org/dna-as-a-biochemical-entity-and-data-string/ |title=DNA as a Biochemical Entity and Data String |date=November 14, 2019 |first1=David M. |last1=Francis |first2=Heather L. |last2=Merk }}</ref>
* Computer settings or parameters, like "<code>?action=edit</code>" as a URL [[query string]]. Often these are intended to be somewhat human-readable, though their primary purpose is to communicate to computers.
 
The term string may also designate a sequence of data or computer records other than characters {{mdash}} like a "string of [[bit]]s" {{mdash}} but when used without qualification it refers to strings of characters.<ref name=Burchfield1986 />
சமூக ஊடகச் சேவையில் நிலை புதுப்பிப்பாக, "இன்று எனக்கு ஒரு புதிய வேலை கிடைத்தது" போன்ற பயனர் உள்ளிட்ட உரை. ஒரு சரத்திற்கு பதிலாக, மென்பொருள் இந்த சரத்தை தரவுத்தளத்தில் சேமிக்கும்.
 
==History==
டிஎன்ஏவின் நியூக்ளிக் அமில வரிசைகளைக் குறிக்கும் "AGATGCCGT" போன்ற அகரவரிசை தரவு.
 
Use of the word "string" to mean any items arranged in a line, series or succession dates back centuries.<ref>{{cite encyclopedia |encyclopedia=The Oxford English Dictionary |volume=X |publisher=Oxford at the Clarendon Press |year=1933 |title=string }}</ref><ref>{{cite web |title=string (n.) |url=https://www.etymonline.com/search?q=string |website=Online Etymology Dictionary }}</ref> In 19th-Century typesetting, [[Compositor (typesetting)|compositors]] used the term "string" to denote a length of type printed on paper; the string would be measured to determine the compositor's pay.<ref>{{cite encyclopedia |encyclopedia=The Century Dictionary |author-link1=William Dwight Whitney |author-link2=Benjamin Eli Smith |first1=William Dwight |last1=Whitney |first2=Benjamin E. |last2=Smith |publisher=The Century Company |___location=New York |page=5994 |title=string }}</ref><ref name=Burchfield1986 /><ref>{{cite news |newspaper=[[Milwaukee Journal Sentinel|Milwaukee Sentinel]] |date=January 11, 1898 |title=Old Union's Demise |page=3 }}</ref>
URL வினவல் சரமாக "?action=edit" போன்ற கணினி அமைப்புகள் அல்லது அளவுருக்கள். பெரும்பாலும் இவை மனிதர்களால் படிக்கக்கூடியதாக இருக்கும், இருப்பினும் அவற்றின் முதன்மை நோக்கம் கணினிகளுடன் தொடர்புகொள்வதாகும்.
 
Use of the word "string" to mean "a sequence of symbols or linguistic elements in a definite order" emerged from mathematics, [[symbolic logic]], and [[linguistic theory]] to speak about the [[formal system|formal]] behavior of symbolic systems, setting aside the symbols' meaning.<ref name=Burchfield1986>{{cite encyclopedia |title=string |encyclopedia=A Supplement to the Oxford English Dictionary |year=1986 |last=Burchfield |first=R.W. |publisher=Oxford at the Clarendon Press |author-link=Robert Burchfield }}</ref>
"பிட்களின் சரம்" போன்ற எழுத்துக்களைத் தவிர வேறு தரவு அல்லது கணினி பதிவுகளின் வரிசையையும் சரம் என்ற சொல் குறிக்கலாம் - ஆனால் தகுதி இல்லாமல் பயன்படுத்தப்படும் போது அது எழுத்துக்களின் சரங்களைக் குறிக்கிறது.
 
For example, logician [[C. I. Lewis]] wrote in 1918:<ref>{{cite book |title=A survey of symbolic logic |___location=Berkeley |publisher=University of California Press |year=1918 |page=355 |last=Lewis |first=C.I. |author-link=C.I. Lewis |url=https://archive.org/details/asurveyofsymboli00lewiuoft/page/355/mode/1up }}</ref>
வரலாறு
<blockquote>
A mathematical system is any set of strings of recognisable marks in which some of the strings are taken initially and the remainder derived from these by operations performed according to rules which are independent of any meaning assigned to the marks. That a system should consist of 'marks' instead of sounds or odours is immaterial.
</blockquote>
 
According to [[Jean E. Sammet]], "the first realistic string handling and pattern matching language" for computers was [[COMIT]] in the 1950s, followed by the [[SNOBOL]] language of the early 1960s.<ref>{{cite journal |url=https://redirect.cs.umbc.edu/courses/undergraduate/331/resources/papers/sammet1972.pdf |journal=Communications of the ACM |first=Jean E. |last=Sammet |title=Programming Languages: History and Future |date=July 1972 |volume=15 |number=7 |doi=10.1145/361454.361485 |s2cid=2003242 }}</ref>
"சரம்" என்ற வார்த்தையின் பயன்பாடானது, ஒரு வரி, தொடர் அல்லது வரிசையாக அமைக்கப்பட்ட எந்தப் பொருளையும் குறிக்கும் வகையில் பல நூற்றாண்டுகளுக்கு முந்தையது. 19 ஆம் நூற்றாண்டின் தட்டச்சு அமைப்பில், காகிதத்தில் அச்சிடப்பட்ட வகையின் நீளத்தைக் குறிக்க இசையமைப்பாளர்கள் "சரம்" என்ற வார்த்தையைப் பயன்படுத்தினர்; இசையமைப்பாளரின் ஊதியத்தை நிர்ணயிக்க சரம் அளவிடப்படும்.
 
== String datatypes ==
"குறியீடுகள் அல்லது மொழியியல் கூறுகளின் ஒரு வரிசை" என்று பொருள்பட "ஸ்ட்ரிங்" என்ற வார்த்தையின் பயன்பாடு கணிதம், குறியீட்டு தர்க்கம் மற்றும் மொழியியல் கோட்பாடு ஆகியவற்றிலிருந்து உருவானது, குறியீட்டு அமைப்புகளின் முறையான நடத்தை பற்றி பேசுவதற்கு, குறியீடுகளின் அர்த்தத்தை ஒதுக்கி வைக்கிறது.
{{See also|Comparison of programming languages (string functions)}}
 
A '''string datatype''' is a datatype modeled on the idea of a formal string. Strings are such an important and useful datatype that they are implemented in nearly every [[programming language]]. In some languages they are available as [[primitive type]]s and in others as [[composite type]]s. The [[syntax]] of most high-level programming languages allows for a string, usually quoted in some way, to represent an instance of a string datatype; such a meta-string is called a ''literal'' or ''string literal''.
உதாரணமாக, தர்க்கவாதி சி.ஐ. லூயிஸ் 1918 இல் எழுதினார்:
 
=== String length ===
ஒரு கணித அமைப்பு என்பது அடையாளம் காணக்கூடிய மதிப்பெண்களின் சரங்களின் தொகுப்பாகும், இதில் சில சரங்கள் ஆரம்பத்தில் எடுக்கப்பட்டு மீதமுள்ளவை மதிப்பெண்களுக்கு ஒதுக்கப்பட்ட எந்த அர்த்தத்தையும் சாராத விதிகளின்படி செய்யப்படும் செயல்பாடுகளால் பெறப்படுகின்றன. ஒரு அமைப்பு ஒலிகள் அல்லது வாசனைகளுக்குப் பதிலாக 'குறிகள்' கொண்டிருக்க வேண்டும் என்பது முக்கியமற்றது.
Although formal strings can have an arbitrary finite length, the length of strings in real languages is often constrained to an artificial maximum. In general, there are two types of string datatypes: ''fixed-length strings'', which have a fixed maximum length to be determined at [[compile time]] and which use the same amount of memory whether this maximum is needed or not, and ''variable-length strings'', whose length is not arbitrarily fixed and which can use varying amounts of memory depending on the actual requirements at run time (see [[Memory management]]). Most strings in modern [[programming languages]] are variable-length strings. Of course, even variable-length strings are limited in length – by the size of available [[computer memory]]. The string length can be stored as a separate integer (which may put another artificial limit on the length) or implicitly through a termination character, usually a character value with all bits zero such as in C programming language. See also "[[#Null-terminated|Null-terminated]]" below.
 
=== Character encoding ===
ஜீன் ஈ. சம்மேட்டின் கூற்றுப்படி, கணினிகளுக்கான "முதல் யதார்த்தமான சரம் கையாளுதல் மற்றும் வடிவ பொருத்தம் மொழி" 1950 களில் COMIT ஆகும், அதைத் தொடர்ந்து 1960 களின் முற்பகுதியில் SNOBOL மொழி.
String datatypes have historically allocated one byte per character, and, although the exact character set varied by region, character encodings were similar enough that programmers could often get away with ignoring this, since characters a program treated specially (such as period and space and comma) were in the same place in all the encodings a program would encounter. These character sets were typically based on [[ASCII]] or [[EBCDIC]]. If text in one encoding was displayed on a system using a different encoding, text was often [[mojibake|mangled]], though often somewhat readable and some computer users learned to read the mangled text.
 
[[Logograph]]ic languages such as [[Chinese language|Chinese]], [[Japanese language|Japanese]], and [[Korean language|Korean]] (known collectively as [[CJK characters|CJK]]) need far more than 256 characters (the limit of a one 8-bit byte per-character encoding) for reasonable representation. The normal solutions involved keeping single-byte representations for ASCII and using two-byte representations for CJK [[ideographs]]. Use of these with existing code led to problems with matching and cutting of strings, the severity of which depended on how the character encoding was designed. Some encodings such as the [[Extended Unix Code|EUC]] family guarantee that a byte value in the ASCII range will represent only that ASCII character, making the encoding safe for systems that use those characters as field separators. Other encodings such as [[ISO-2022]] and [[Shift-JIS]] do not make such guarantees, making matching on byte codes unsafe. These encodings also were not "self-synchronizing", so that locating character boundaries required backing up to the start of a string, and pasting two strings together could result in corruption of the second string.
== சரம் தரவு வகைகள் ==
{{See also|Comparison of programming languages (string functions)}}
 
[[Unicode]] has simplified the picture somewhat. Most programming languages now have a datatype for Unicode strings. Unicode's preferred byte stream format [[UTF-8]] is designed not to have the problems described above for older multibyte encodings. UTF-8, UTF-16 and [[UTF-32]] require the programmer to know that the fixed-size code units are different from the "characters", the main difficulty currently is incorrectly designed APIs that attempt to hide this difference (UTF-32 does make ''code points'' fixed-sized, but these are not "characters" due to composing codes).
ஒரு சரம் தரவு வகை என்பது ஒரு முறையான சரத்தின் யோசனையின் அடிப்படையில் வடிவமைக்கப்பட்ட ஒரு தரவு வகை ஆகும். சரங்கள் ஒரு முக்கியமான மற்றும் பயனுள்ள தரவு வகையாகும், அவை கிட்டத்தட்ட ஒவ்வொரு நிரலாக்க மொழியிலும் செயல்படுத்தப்படுகின்றன. சில மொழிகளில் அவை பழமையான வகைகளாகவும் மற்றவற்றில் கூட்டு வகைகளாகவும் கிடைக்கின்றன. பெரும்பாலான உயர்-நிலை நிரலாக்க மொழிகளின் தொடரியல், சரம் தரவு வகையின் நிகழ்வைப் பிரதிநிதித்துவப்படுத்த, வழக்கமாக ஏதேனும் ஒரு வகையில் மேற்கோள் காட்டப்படும் சரத்தை அனுமதிக்கிறது; அத்தகைய மெட்டா-சரம் ஒரு எழுத்து அல்லது சரம் எழுத்து என்று அழைக்கப்படுகிறது.
 
=== Implementations ===
முறையான சரங்கள் தன்னிச்சையான வரையறுக்கப்பட்ட நீளத்தைக் கொண்டிருக்கலாம் என்றாலும், உண்மையான மொழிகளில் சரங்களின் நீளம் பெரும்பாலும் செயற்கை அதிகபட்சமாக கட்டுப்படுத்தப்படுகிறது. பொதுவாக, இரண்டு வகையான சரம் தரவு வகைகள் உள்ளன: நிலையான-நீள சரங்கள், தொகுக்கும் நேரத்தில் தீர்மானிக்கப்பட வேண்டிய நிலையான அதிகபட்ச நீளம் மற்றும் இந்த அதிகபட்சம் தேவையா அல்லது இல்லாவிட்டாலும் அதே அளவு நினைவகத்தைப் பயன்படுத்தும், மற்றும் மாறி-நீள சரங்கள், அதன் நீளம் தன்னிச்சையாக நிர்ணயிக்கப்படவில்லை மற்றும் இயக்க நேரத்தில் உண்மையான தேவைகளைப் பொறுத்து பல்வேறு அளவு நினைவகத்தைப் பயன்படுத்தலாம் (நினைவக மேலாண்மையைப் பார்க்கவும்). நவீன நிரலாக்க மொழிகளில் பெரும்பாலான சரங்கள் மாறி-நீள சரங்களாகும். நிச்சயமாக, மாறி-நீள சரங்கள் கூட நீளத்தில் வரையறுக்கப்பட்டுள்ளன - கிடைக்கக்கூடிய கணினி நினைவகத்தின் அளவு. சரத்தின் நீளம் ஒரு தனி முழு எண்ணாக (நீளத்தின் மீது மற்றொரு செயற்கை வரம்பை வைக்கலாம்) அல்லது மறைமுகமாக ஒரு முடிவு எழுத்து மூலம் சேமிக்கப்படும், பொதுவாக C நிரலாக்க மொழி போன்ற அனைத்து பிட்கள் பூஜ்ஜியத்துடன் ஒரு எழுத்து மதிப்பு. கீழே உள்ள "Null-terminated" என்பதையும் பார்க்கவும்.
{{anchor|String Buffers}}
Some languages, such as [[C++]], [[Perl]] and [[Ruby (programming language)|Ruby]], normally allow the contents of a string to be changed after it has been created; these are termed ''mutable'' strings. In other languages, such as [[Java (programming language)|Java]], [[JavaScript]], [[Lua (programming language)|Lua]], [[Python (programming language)|Python]], and [[Go (programming language)|Go]], the value is fixed and a new string must be created if any alteration is to be made; these are termed ''immutable'' strings. Some of these languages with immutable strings also provide another type that is mutable, such as Java and [[.NET Framework|.NET]]'s {{Javadoc:SE|java/lang|StringBuilder}}, the thread-safe Java {{Javadoc:SE|java/lang|StringBuffer}}, and the [[Cocoa (API)|Cocoa]] <code>NSMutableString</code>. There are both advantages and disadvantages to immutability: although immutable strings may require inefficiently creating many copies, they are simpler and completely [[Thread safety|thread-safe]].
 
Strings are typically implemented as [[array data type|arrays]] of bytes, characters, or code units, in order to allow fast access to individual units or substrings—including characters when they have a fixed length. A few languages such as [[Haskell (programming language)|Haskell]] implement them as [[linked list]]s instead.
=== எழுத்து குறியாக்கம் ===
சரம் தரவு வகைகள் வரலாற்று ரீதியாக ஒரு எழுத்துக்கு ஒரு பைட்டை ஒதுக்கியுள்ளன, மேலும், குறிப்பிட்ட எழுத்துக்குறிகள் பிராந்தியத்தின் அடிப்படையில் வேறுபட்டாலும், எழுத்துக்குறி குறியாக்கங்கள் ஒரே மாதிரியாக இருந்தன, புரோகிராமர்கள் இதைப் புறக்கணிப்பதில் இருந்து விடுபடலாம், ஏனெனில் ஒரு நிரல் சிறப்பாகக் கருதப்படும் (காலம் மற்றும் இடம் மற்றும் கமா போன்றவை. ) ஒரு நிரல் சந்திக்கும் அனைத்து குறியாக்கங்களிலும் ஒரே இடத்தில் இருந்தது. இந்த எழுத்துத் தொகுப்புகள் பொதுவாக ASCII அல்லது EBCDICஐ அடிப்படையாகக் கொண்டவை. ஒரு குறியாக்கத்தில் உள்ள உரை வேறு குறியாக்கத்தைப் பயன்படுத்தி கணினியில் காட்டப்பட்டால், உரை பெரும்பாலும் சிதைந்துவிடும், பெரும்பாலும் ஓரளவு படிக்கக்கூடியது மற்றும் சில கணினி பயனர்கள் சிதைந்த உரையைப் படிக்க கற்றுக்கொண்டனர்.
 
Some languages, such as [[Prolog]] and [[Erlang (programming language)|Erlang]], avoid implementing a dedicated string datatype at all, instead adopting the convention of representing strings as lists of character codes.
சீன, ஜப்பானிய மற்றும் கொரியன் போன்ற லோகோகிராஃபிக் மொழிகளுக்கு (ஒட்டுமொத்தமாக CJK என அழைக்கப்படுகிறது) நியாயமான பிரதிநிதித்துவத்திற்கு 256 எழுத்துகளுக்கு மேல் (ஒரு எழுத்துக்கு ஒரு 8-பிட் பைட்டின் வரம்பு) தேவைப்படுகிறது. ASCIIக்கான ஒற்றை-பைட் பிரதிநிதித்துவங்களை வைத்திருப்பது மற்றும் CJK ஐடியோகிராஃப்களுக்கு இரண்டு-பைட் பிரதிநிதித்துவங்களைப் பயன்படுத்துவது ஆகியவை இயல்பான தீர்வுகளை உள்ளடக்கியது. ஏற்கனவே உள்ள குறியீட்டுடன் இவற்றைப் பயன்படுத்துவது சரங்களை பொருத்துதல் மற்றும் வெட்டுதல் ஆகியவற்றில் சிக்கல்களை ஏற்படுத்தியது, இதன் தீவிரம் எழுத்து குறியாக்கம் எவ்வாறு வடிவமைக்கப்பட்டது என்பதைப் பொறுத்தது. EUC குடும்பம் போன்ற சில குறியாக்கங்கள், ASCII வரம்பில் உள்ள பைட் மதிப்பு அந்த ASCII எழுத்தை மட்டுமே குறிக்கும் என்று உத்தரவாதம் அளிக்கிறது, அந்த எழுத்துகளை புலப் பிரிப்பான்களாகப் பயன்படுத்தும் கணினிகளுக்கு குறியாக்கத்தைப் பாதுகாப்பானதாக ஆக்குகிறது. ISO-2022 மற்றும் Shift-JIS போன்ற பிற குறியாக்கங்கள் அத்தகைய உத்தரவாதங்களை வழங்காது, பைட் குறியீடுகளில் பொருத்தம் பாதுகாப்பற்றதாக ஆக்குகிறது. இந்த குறியாக்கங்களும் "சுய-ஒத்திசைவு" இல்லை, எனவே எழுத்து எல்லைகளைக் கண்டறிவதற்கு ஒரு சரத்தின் தொடக்கம் வரை காப்புப் பிரதி எடுக்க வேண்டும், மேலும் இரண்டு சரங்களை ஒன்றாக ஒட்டுவது இரண்டாவது சரத்தின் சிதைவை ஏற்படுத்தும்.
 
=== Representations ===
யுனிகோட் படத்தை ஓரளவு எளிமையாக்கியுள்ளது. பெரும்பாலான நிரலாக்க மொழிகளில் இப்போது யூனிகோட் சரங்களுக்கான தரவு வகை உள்ளது. யூனிகோடின் விருப்பமான பைட் ஸ்ட்ரீம் வடிவம் UTF-8 ஆனது பழைய மல்டிபைட் குறியாக்கங்களுக்கு மேலே விவரிக்கப்பட்ட சிக்கல்கள் இல்லாத வகையில் வடிவமைக்கப்பட்டுள்ளது. UTF-8, UTF-16 மற்றும் UTF-32 ஆகியவை நிலையான அளவு குறியீட்டு அலகுகள் "எழுத்துக்களிலிருந்து" வேறுபட்டவை என்பதை புரோகிராமர் அறிந்து கொள்ள வேண்டும், இந்த வித்தியாசத்தை மறைக்க முயலும் APIகள் தவறாக வடிவமைக்கப்பட்டுள்ளது (UTF-32 செய்கிறது. குறியீடு புள்ளிகளை நிலையான அளவில் உருவாக்கவும், ஆனால் குறியீடுகளை உருவாக்குவதால் இவை "எழுத்துகள்" அல்ல).
Representations of strings depend heavily on the choice of character repertoire and the method of character encoding. Older string implementations were designed to work with repertoire and encoding defined by ASCII, or more recent extensions like the [[ISO 8859]] series. Modern implementations often use the extensive repertoire defined by Unicode along with a variety of complex encodings such as UTF-8 and UTF-16.
 
The term ''byte string'' usually indicates a general-purpose string of bytes, rather than strings of only (readable) characters, strings of bits, or such. Byte strings often imply that bytes can take any value and any data can be stored as-is, meaning that there should be no value interpreted as a termination value.
=== அமலாக்கங்கள் ===
{{anchor|String Buffers}}
Some languages,C++, Perl மற்றும் Ruby போன்றவை, ஒரு சரத்தின் உள்ளடக்கங்களை உருவாக்கிய பிறகு மாற்ற அனுமதிக்கின்றன; இவை மாறக்கூடிய சரங்கள் என்று அழைக்கப்படுகின்றன. ஜாவா, ஜாவாஸ்கிரிப்ட், லுவா, பைதான் மற்றும் கோ போன்ற பிற மொழிகளில், மதிப்பு நிலையானது மற்றும் ஏதேனும் மாற்றங்களைச் செய்ய வேண்டுமானால் புதிய சரம் உருவாக்கப்பட வேண்டும்; இவை மாறாத சரங்கள் என்று அழைக்கப்படுகின்றன. ஜாவா மற்றும் .NET இன் StringBuilder, நூல்-பாதுகாப்பான Java StringBuffer மற்றும் Cocoa NSMutableString போன்ற மாறக்கூடிய மற்றொரு வகையையும் இந்த மொழிகள் சில மாறாத சரங்களைக் கொண்டுள்ளன. மாறாத தன்மைக்கு நன்மைகள் மற்றும் தீமைகள் இரண்டும் உள்ளன: மாறாத சரங்களுக்கு பல பிரதிகளை திறமையாக உருவாக்க வேண்டியிருந்தாலும், அவை எளிமையானவை மற்றும் முற்றிலும் நூல்-பாதுகாப்பானவை.
 
Most string implementations are very similar to variable-length [[Array data type|array]]s with the entries storing the [[character code]]s of corresponding characters. The principal difference is that, with certain encodings, a single logical character may take up more than one entry in the array. This happens for example with UTF-8, where single codes ([[Universal Character Set|UCS]] code points) can take anywhere from one to four bytes, and single characters can take an arbitrary number of codes. In these cases, the logical length of the string (number of characters) differs from the physical length of the array (number of bytes in use). [[UTF-32]] avoids the first part of the problem.
சரங்கள் பொதுவாக பைட்டுகள், எழுத்துகள் அல்லது குறியீடு அலகுகளின் வரிசைகளாக செயல்படுத்தப்படுகின்றன, அவை தனித்தனி அலகுகள் அல்லது துணைச்சரங்களை விரைவாக அணுக அனுமதிக்கின்றன-அவை நிலையான நீளத்தைக் கொண்டிருக்கும்போது எழுத்துக்கள் உட்பட. ஹாஸ்கெல் போன்ற சில மொழிகள் அவற்றை இணைக்கப்பட்ட பட்டியல்களாக செயல்படுத்துகின்றன.
 
==== Null-terminated ====
ப்ரோலாக் மற்றும் எர்லாங் போன்ற சில மொழிகள், ஒரு பிரத்யேக சரம் தரவு வகையைச் செயல்படுத்துவதைத் தவிர்க்கின்றன, அதற்குப் பதிலாக எழுத்துக் குறியீடுகளின் பட்டியலாக சரங்களைக் குறிக்கும் மரபுகளைப் பின்பற்றுகின்றன.
{{Main|Null-terminated string}}
 
The length of a string can be stored implicitly by using a special terminating character; often this is the [[null character]] (NUL), which has all bits zero, a convention used and perpetuated by the popular [[C (programming language)|C programming language]].<ref>
=== பிரதிநிதித்துவங்கள் ===
{{Citation
சரங்களின் பிரதிநிதித்துவங்கள் எழுத்துத் தொகுப்பின் தேர்வு மற்றும் எழுத்துக்குறி குறியீட்டு முறையைப் பெரிதும் சார்ந்துள்ளது. பழைய சரம் செயலாக்கங்கள் ASCII ஆல் வரையறுக்கப்பட்ட திறமை மற்றும் குறியாக்கத்துடன் வேலை செய்ய வடிவமைக்கப்பட்டுள்ளன, அல்லது ISO 8859 தொடர் போன்ற சமீபத்திய நீட்டிப்புகள். UTF-8 மற்றும் UTF-16 போன்ற பல்வேறு சிக்கலான குறியாக்கங்களுடன் யுனிகோட் மூலம் வரையறுக்கப்பட்ட விரிவான திறனாய்வுகளை நவீன செயலாக்கங்கள் பெரும்பாலும் பயன்படுத்துகின்றன.
|last1 = Bryant
|first1 = Randal E.
|author-link = Randal Bryant
|last2 = David
|first2 = O'Hallaron
|title = Computer Systems: A Programmer's Perspective
|place = Upper Saddle River, NJ
|publisher = Pearson Education
|year = 2003
|edition = 2003
|url = http://csapp.cs.cmu.edu/
|isbn = 0-13-034074-X
|page = 40
|url-status = live
|archive-url = https://web.archive.org/web/20070806075942/http://csapp.cs.cmu.edu/
|archive-date = 2007-08-06
}}
</ref> Hence, this representation is commonly referred to as a '''C string'''. This representation of an ''n''-character string takes ''n'' + 1 space (1 for the terminator), and is thus an [[implicit data structure]].
 
In terminated strings, the terminating code is not an allowable character in any string. Strings with ''length'' field do not have this limitation and can also store arbitrary [[binary data]].
பைட் சரம் என்ற சொல் பொதுவாக (படிக்கக்கூடிய) எழுத்துக்கள், பிட்களின் சரங்கள் அல்லது பலவற்றைக் காட்டிலும், பைட்டுகளின் பொது நோக்க சரத்தை குறிக்கிறது. பைட் சரங்கள் பெரும்பாலும் பைட்டுகள் எந்த மதிப்பையும் எடுத்துக் கொள்ளலாம் மற்றும் எந்தத் தரவையும் அப்படியே சேமிக்கலாம், அதாவது முடிவு மதிப்பாக எந்த மதிப்பும் விளக்கப்படக்கூடாது.
 
An example of a ''null-terminated string'' stored in a 10-byte [[Buffer (computer science)|buffer]], along with its [[ASCII]] (or more modern [[UTF-8]]) representation as 8-bit [[hexadecimal number]]s is:
 
பெரும்பாலான சரம் செயலாக்கங்கள் மாறி-நீள வரிசைகளுடன் தொடர்புடைய எழுத்துக்களின் எழுத்துக்குறி குறியீடுகளை சேமிக்கும் உள்ளீடுகளுடன் மிகவும் ஒத்ததாக இருக்கும். முக்கிய வேறுபாடு என்னவென்றால், சில குறியாக்கங்களுடன், ஒரு தருக்க எழுத்து வரிசையில் ஒன்றுக்கு மேற்பட்ட உள்ளீடுகளை எடுக்கலாம். உதாரணமாக, UTF-8 இல் இது நிகழ்கிறது, இங்கு ஒற்றை குறியீடுகள் (UCS குறியீடு புள்ளிகள்) ஒன்று முதல் நான்கு பைட்டுகள் வரை எங்கும் எடுக்கலாம், மேலும் ஒற்றை எழுத்துகள் தன்னிச்சையான குறியீடுகளை எடுக்கலாம். இந்த சந்தர்ப்பங்களில், சரத்தின் தருக்க நீளம் (எழுத்துகளின் எண்ணிக்கை) அணிவரிசையின் இயற்பியல் நீளத்திலிருந்து (பயன்படுத்தும் பைட்டுகளின் எண்ணிக்கை) வேறுபடுகிறதுh its [[ASCII]] (or more modern [[UTF-8]]) representation as 8-bit [[hexadecimal number]]s is:
{| class="wikitable" style="margin-left: auto; margin-right:auto"
|-
Line 83 ⟶ 112:
|}
 
The length of the string in the above example, "<code>FRANK</code>", is 5 characters, but it occupies 6 bytes. Characters after the terminator do not form part of the representation; they may be either part of other data or just garbage. (Strings of this form are sometimes called ''ASCIZ strings'', after the original [[assembly language]] directive used to declare them.)
மேலே உள்ள எடுத்துக்காட்டில் உள்ள சரத்தின் நீளம், "FRANK", 5 எழுத்துகள், ஆனால் அது 6 பைட்டுகளை ஆக்கிரமித்துள்ளது. டெர்மினேட்டருக்குப் பின் வரும் எழுத்துக்கள் பிரதிநிதித்துவத்தின் ஒரு பகுதியாக இல்லை; அவை மற்ற தரவுகளின் பகுதியாகவோ அல்லது குப்பையாகவோ இருக்கலாம். (இந்த வடிவத்தின் சரங்கள் சில நேரங்களில் ASCIZ சரங்கள் என்று அழைக்கப்படுகின்றன, அவற்றை அறிவிக்கப் பயன்படுத்தப்படும் அசல் சட்டசபை மொழி உத்தரவுக்குப் பிறகு.)
 
==== Byte- and bit-terminated ====
==== பைட்- மற்றும் பிட்-டெர்மினேட் ====
Using a special byte other than null for terminating strings has historically appeared in both hardware and software, though sometimes with a value that was also a printing character. <code>$</code> was used by many assembler systems, <code>:</code> used by [[Control Data Corporation|CDC]] systems (this character had a value of zero), and the [[ZX80]] used <code>"</code><ref name=asm>{{cite web|last1=Wearmouth |first1=Geoff |title=An Assembly Listing of the ROM of the Sinclair ZX80 |url=http://www.wearmouth.demon.co.uk/zx80.htm |url-status=unfit |archive-url=https://web.archive.org/web/20150815035611/http://www.wearmouth.demon.co.uk/zx80.htm |archive-date=August 15, 2015 }}</ref> since this was the string delimiter in its BASIC language.
சரங்களை நிறுத்துவதற்கு பூஜ்யத்தைத் தவிர வேறு ஒரு சிறப்பு பைட்டைப் பயன்படுத்துவது வரலாற்று ரீதியாக வன்பொருள் மற்றும் மென்பொருள் இரண்டிலும் தோன்றியது, இருப்பினும் சில சமயங்களில் ஒரு மதிப்பு அச்சிடும் தன்மையாகவும் இருந்தது. $ பல அசெம்பிளர் அமைப்புகளால் பயன்படுத்தப்பட்டது, : CDC அமைப்புகளால் பயன்படுத்தப்பட்டது (இந்த எழுத்து பூஜ்ஜியத்தின் மதிப்பைக் கொண்டிருந்தது), மற்றும் ZX80 பயன்படுத்தப்பட்டது, ஏனெனில் இது அதன் அடிப்படை மொழியில் ஸ்ட்ரிங் டிலிமிட்டராக இருந்தது.
 
Somewhat similar, "data processing" machines like the [[IBM 1401]] used a special [[Word mark (computer hardware)|word mark]] bit to delimit strings at the left, where the operation would start at the right. This bit had to be clear in all other parts of the string. This meant that, while the IBM 1401 had a seven-bit word, almost no-one ever thought to use this as a feature, and override the assignment of the seventh bit to (for example) handle ASCII codes.
சற்றே ஒத்த, IBM 1401 போன்ற "தரவு செயலாக்க" இயந்திரங்கள் இடதுபுறத்தில் உள்ள சரங்களை வரையறுக்க ஒரு சிறப்பு சொல் குறி பிட்டைப் பயன்படுத்துகின்றன, அங்கு செயல்பாடு வலதுபுறத்தில் தொடங்கும். இந்த பிட் சரத்தின் மற்ற எல்லா பகுதிகளிலும் தெளிவாக இருக்க வேண்டும். இதன் பொருள், IBM 1401 ஏழு-பிட் வார்த்தையைக் கொண்டிருந்தாலும், இதை ஒரு அம்சமாகப் பயன்படுத்த யாரும் நினைக்கவில்லை, மேலும் ASCII குறியீடுகளைக் கையாள (உதாரணமாக) ஏழாவது பிட்டின் ஒதுக்கீட்டை மேலெழுதியது.
 
Early microcomputer software relied upon the fact that ASCII codes do not use the high-order bit, and set it to indicate the end of a string. It must be reset to 0 prior to output.<ref>{{cite web |last1=Allison |first1=Dennis |title=Design Notes for Tiny BASIC |url=http://www.ittybittycomputers.com/IttyBitty/TinyBasic/DDJ1/Design.html |url-status=live |archive-url=https://web.archive.org/web/20170410220759/http://www.ittybittycomputers.com/IttyBitty/TinyBasic/DDJ1/Design.html |archive-date=2017-04-10 }}</ref>
ஆரம்பகால மைக்ரோகம்ப்யூட்டர் மென்பொருளானது, ASCII குறியீடுகள் உயர்-வரிசை பிட்டைப் பயன்படுத்துவதில்லை என்ற உண்மையை நம்பியிருந்தது, மேலும் ஒரு சரத்தின் முடிவைக் குறிக்க அதை அமைத்தது. வெளியீட்டிற்கு முன் அதை 0 க்கு மீட்டமைக்க வேண்டும்.
 
==== Length-prefixed ====
==== நீளம்-முன்னொட்டு ====
The length of a string can also be stored explicitly, for example by prefixing the string with the length as a byte value. This convention is used in many [[Pascal (programming language)|Pascal]] dialects; as a consequence, some people call such a string a '''Pascal string''' or '''P-string'''. Storing the string length as byte limits the maximum string length to 255. To avoid such limitations, improved implementations of P-strings use 16-, 32-, or 64-bit [[Word (data type)|words]] to store the string length. When the ''length'' field covers the [[address space]], strings are limited only by the [[Dynamic memory allocation|available memory]].
ஒரு சரத்தின் நீளத்தையும் வெளிப்படையாகச் சேமிக்க முடியும், எடுத்துக்காட்டாக, சரத்தை பைட் மதிப்பாக நீளத்துடன் முன்னொட்டு வைப்பதன் மூலம். இந்த மாநாடு பல பாஸ்கல் பேச்சுவழக்குகளில் பயன்படுத்தப்படுகிறது; இதன் விளைவாக, சிலர் அத்தகைய சரத்தை பாஸ்கல் சரம் அல்லது பி-ஸ்ட்ரிங் என்று அழைக்கிறார்கள். சரத்தின் நீளத்தை பைட்டாக சேமிப்பது அதிகபட்ச சரத்தின் நீளத்தை 255 ஆகக் கட்டுப்படுத்துகிறது. அத்தகைய வரம்புகளைத் தவிர்க்க, P-ஸ்ட்ரிங்ஸின் மேம்படுத்தப்பட்ட செயலாக்கங்கள் சரத்தின் நீளத்தை சேமிக்க 16-, 32- அல்லது 64-பிட் வார்த்தைகளைப் பயன்படுத்துகின்றன. நீள புலம் முகவரி இடத்தை உள்ளடக்கும் போது, ​​கிடைக்கும் நினைவகத்தால் மட்டுமே சரங்கள் வரையறுக்கப்படும்.
நீளம் வரம்பிடப்பட்டால், அது நிலையான இடத்தில் குறியாக்கம் செய்யப்படலாம், பொதுவாக ஒரு இயந்திர வார்த்தை, இதனால் ஒரு மறைமுகமான தரவு கட்டமைப்பிற்கு வழிவகுக்கும், n + k இடத்தை எடுத்துக்கொள்கிறது, இங்கு k என்பது ஒரு வார்த்தையில் உள்ள எழுத்துக்களின் எண்ணிக்கை (8-பிட்க்கு 8 64-பிட் கணினியில் ASCII, 32-பிட் இயந்திரத்தில் 32-பிட் UTF-32/UCS-4, போன்றவை). நீளம் வரம்பில் இல்லை என்றால், நீளம் n குறியாக்கம் log(n) இடத்தைப் பெறுகிறது (நிலையான-நீளக் குறியீட்டைப் பார்க்கவும்), எனவே நீளம்-முன்னொட்டு சரங்கள் ஒரு சுருக்கமான தரவு கட்டமைப்பாகும், இது log(n) + n இடைவெளியில் n நீளத்தின் சரத்தை குறியாக்கம் செய்கிறது. .
 
If the length is bounded, then it can be encoded in constant space, typically a machine word, thus leading to an [[implicit data structure]], taking ''n'' + ''k'' space, where ''k'' is the number of characters in a word (8 for 8-bit ASCII on a 64-bit machine, 1 for 32-bit UTF-32/UCS-4 on a 32-bit machine, etc.).
பிந்தைய வழக்கில், நீளம்-முன்னொட்டு புலம் நிலையான நீளத்தைக் கொண்டிருக்கவில்லை, எனவே சரம் வளரும்போது உண்மையான சரம் தரவை நகர்த்த வேண்டும், அதாவது நீள புலத்தை அதிகரிக்க வேண்டும்.<!---commented out: while NULL-terminated string allow for pointers to proper substrings, length-prefixed strings do not; a pointer to a length-prefixed string has to point to the length field, which remains at the same ___location after growing--- but the downside is that any direct pointers to the string data get invalidated (they should move by one).--->
If the length is not bounded, encoding a length ''n'' takes log(''n'') space (see [[fixed-length code]]), so length-prefixed strings are a [[succinct data structure]], encoding a string of length ''n'' in log(''n'') + ''n'' space.
 
In the latter case, the length-prefix field itself does not have fixed length, therefore the actual string data needs to be moved when the string grows such that the length field needs to be increased.<!---commented out: "bad" is not an issue in a technical encyclopedic article---This in itself is not that bad since the number of bytes is just logarithmic on the length of string,---><!---commented out: while NULL-terminated string allow for pointers to proper substrings, length-prefixed strings do not; a pointer to a length-prefixed string has to point to the length field, which remains at the same ___location after growing--- but the downside is that any direct pointers to the string data get invalidated (they should move by one).--->
ASCII / UTF-8 பிரதிநிதித்துவத்துடன் 10-பைட் பஃப்பரில் சேமிக்கப்பட்ட பாஸ்கல் சரம் இங்கே:
 
Here is a Pascal string stored in a 10-byte buffer, along with its ASCII / UTF-8 representation:
நீளம் F R A N K k e f w
 
{| class="wikitable" style="margin-left: auto; margin-right:auto"
0516 4616 5216 4116 4E16 4B16 6B16 6516 6616 7716
|-
| <small>length</small>
| <code>F</code> || <code>R</code> || <code>A</code> || <code>N</code> || <code>K</code>
| style="background: #DDD" | <code style="background: #DDD">k</code>
| style="background: #DDD" | <code style="background: #DDD">e</code>
| style="background: #DDD" | <code style="background: #DDD">f</code>
| style="background: #DDD" | <code style="background: #DDD">w</code>
|-
| 05<sub>16</sub>
| 46<sub>16</sub> || 52<sub>16</sub> || 41<sub>16</sub> || 4E<sub>16</sub> || 4B<sub>16</sub>
| style="background: #DDD" | 6B<sub>16</sub>
| style="background: #DDD" | 65<sub>16</sub>
| style="background: #DDD" | 66<sub>16</sub>
| style="background: #DDD" | 77<sub>16</sub>
|}
 
==== Strings as records ====
==== பதிவுகளாக சரங்கள் ====
Many languages, including object-oriented ones, implement strings as [[record (computer science)|record]]s with an internal structure like:
பொருள் சார்ந்த மொழிகள் உட்பட பல மொழிகள், சரங்களை போன்ற உள் அமைப்புடன் பதிவுகளாக செயல்படுத்துகின்றன:
 
<syntaxhighlight lang="cpp">
Line 114 ⟶ 158:
</syntaxhighlight>
 
However, since the implementation is usually [[information hiding|hidden]], the string must be accessed and modified through member functions. <code>text</code> is a pointer to a dynamically allocated memory area, which might be expanded as needed. See also [[string (C++)]].
இருப்பினும், செயலாக்கம் பொதுவாக மறைக்கப்பட்டிருப்பதால், உறுப்பினர் செயல்பாடுகள் மூலம் சரத்தை அணுகி மாற்றியமைக்க வேண்டும். உரை என்பது மாறும் வகையில் ஒதுக்கப்பட்ட நினைவக பகுதிக்கு ஒரு சுட்டி ஆகும், இது தேவைக்கேற்ப விரிவாக்கப்படலாம். சரத்தையும் (C++) பார்க்கவும்.
 
==== Other representations ====
==== பிற பிரதிநிதித்துவங்கள் ====
Both character termination and length codes limit strings: For example, C character arrays that contain null (NUL) characters cannot be handled directly by [[C string handling|C string]] library functions: Strings using a length code are limited to the maximum value of the length code.
எழுத்து முடிப்பு மற்றும் நீளக் குறியீடுகள் இரண்டும் சரங்களைக் கட்டுப்படுத்துகின்றன: எடுத்துக்காட்டாக, பூஜ்ய (NUL) எழுத்துக்களைக் கொண்ட C எழுத்து வரிசைகளை C சரம் நூலகச் செயல்பாடுகளால் நேரடியாகக் கையாள முடியாது: நீளக் குறியீட்டைப் பயன்படுத்தும் சரங்கள் நீளக் குறியீட்டின் அதிகபட்ச மதிப்புக்கு வரம்பிடப்படும்.
 
Both of these limitations can be overcome by clever programming.
இந்த இரண்டு வரம்புகளையும் புத்திசாலித்தனமான நிரலாக்கத்தால் கடக்க முடியும்.
 
It is possible to create data structures and functions that manipulate them that do not have the problems associated with character termination and can in principle overcome length code bounds. It is also possible to optimize the string represented using techniques from [[Run-length encoding|run length encoding]] (replacing repeated characters by the character value and a length) and [[Hamming coding|Hamming encoding]]{{ clarify | date = June 2015 | reason = did you mean Huffman compression? Or do we need a few more words about error correction coding here? I don't see how either one helps us find out how long the string is. }}.
தரவு கட்டமைப்புகள் மற்றும் செயல்பாடுகளை உருவாக்குவது சாத்தியமாகும், அவை எழுத்து நீக்கத்துடன் தொடர்புடைய சிக்கல்களைக் கொண்டிருக்கவில்லை மற்றும் கொள்கையளவில் நீளக் குறியீடு வரம்புகளைக் கடக்க முடியும். ரன் லெந்த் குறியாக்கம் (எழுத்து மதிப்பு மற்றும் நீளத்தின் மூலம் மீண்டும் மீண்டும் வரும் எழுத்துக்களை மாற்றுதல்) மற்றும் ஹேமிங் குறியாக்கம் [தெளிவுபடுத்துதல் தேவை] நுட்பங்களைப் பயன்படுத்தி குறிப்பிடப்படும் சரத்தை மேம்படுத்தவும் முடியும்.
 
While these representations are common, others are possible. Using [[Rope (data structure)|rope]]s makes certain string operations, such as insertions, deletions, and concatenations more efficient.
இந்த பிரதிநிதித்துவங்கள் பொதுவானவை என்றாலும், மற்றவை சாத்தியமாகும். கயிறுகளைப் பயன்படுத்துவது, செருகல், நீக்குதல் மற்றும் இணைத்தல் போன்ற சில சரம் செயல்பாடுகளை மிகவும் திறமையானதாக்குகிறது.
 
The core data structure in a [[text editor]] is the one that manages the string (sequence of characters) that represents the current state of the file being edited.
டெக்ஸ்ட் எடிட்டரில் உள்ள கோர் டேட்டா கட்டமைப்பானது, திருத்தப்படும் கோப்பின் தற்போதைய நிலையைக் குறிக்கும் சரத்தை (எழுத்துகளின் வரிசை) நிர்வகிக்கிறது. அந்த நிலையை ஒரு நீண்ட தொடர்ச்சியான எழுத்துக்களில் சேமிக்க முடியும் என்றாலும், ஒரு பொதுவான உரை எடிட்டர் அதன் வரிசை தரவு கட்டமைப்பாக மாற்று பிரதிநிதித்துவத்தை பயன்படுத்துகிறது - ஒரு இடைவெளி இடையக, வரிகளின் இணைக்கப்பட்ட பட்டியல், ஒரு துண்டு அட்டவணை அல்லது ஒரு கயிறு. செருகல்கள், நீக்குதல்கள் மற்றும் முந்தைய திருத்தங்களை செயல்தவிர்ப்பது போன்ற சில சரம் செயல்பாடுகள் மிகவும் திறமையானவை.
While that state could be stored in a single long consecutive array of characters, a typical text editor instead uses an alternative representation as its sequence data structure—a [[gap buffer]], a [[linked list]] of lines, a [[piece table]], or a [[Rope (data structure)|rope]]—which makes certain string operations, such as insertions, deletions, and undoing previous edits, more efficient.<ref>
Charles Crowley.
[http://www.cs.unm.edu/~crowley/papers/sds.pdf "Data Structures for Text Sequences"] {{webarchive|url=https://web.archive.org/web/20160304042917/https://www.cs.unm.edu/~crowley/papers/sds.pdf |date=2016-03-04 }}.
Section
[http://www.cs.unm.edu/~crowley/papers/sds/node1.html "Introduction"] {{webarchive|url=https://web.archive.org/web/20160404020539/http://www.cs.unm.edu/~crowley/papers/sds/node1.html |date=2016-04-04 }}.
</ref>
 
=== Security concerns ===
Line 132 ⟶ 182:
String data is frequently obtained from user input to a program. As such, it is the responsibility of the program to validate the string to ensure that it represents the expected format. Performing [[Improper input validation|limited or no validation]] of user input can cause a program to be vulnerable to [[code injection]] attacks.
 
== Literal strings ==
== எழுத்துச் சரங்கள் ==
{{Main|String literal}}
 
Sometimes, strings need to be embedded inside a text file that is both human-readable and intended for consumption by a machine. This is needed in, for example, source code of programming languages, or in configuration files. In this case, the NUL character does not work well as a terminator since it is normally invisible (non-printable) and is difficult to input via a keyboard. Storing the string length would also be inconvenient as manual computation and tracking of the length is tedious and error-prone.
சில சமயங்களில், மனிதர்கள் படிக்கக்கூடிய மற்றும் ஒரு இயந்திரத்தின் நுகர்வுக்கான உரைக் கோப்பின் உள்ளே சரங்களை உட்பொதிக்க வேண்டும். எடுத்துக்காட்டாக, நிரலாக்க மொழிகளின் மூலக் குறியீடு அல்லது உள்ளமைவு கோப்புகளில் இது தேவைப்படுகிறது. இந்த நிலையில், NUL எழுத்து ஒரு டெர்மினேட்டராக நன்றாக வேலை செய்யாது, ஏனெனில் இது பொதுவாக கண்ணுக்கு தெரியாதது (அச்சிட முடியாதது) மற்றும் விசைப்பலகை வழியாக உள்ளீடு செய்வது கடினம். கைமுறையாகக் கணக்கிடுதல் மற்றும் நீளத்தைக் கண்காணிப்பது கடினமானது மற்றும் பிழை ஏற்படக்கூடியது என்பதால் சரத்தின் நீளத்தை சேமிப்பதும் சிரமமாக இருக்கும்.
 
Two common representations are:
இரண்டு பொதுவான பிரதிநிதித்துவங்கள்:
* Surrounded by [[quotation mark]]s (ASCII [[hexadecimal#Using 0–9 and A–F|0x22]] double quote <code>"str"</code> or ASCII 0x27 single quote <code>'str'</code>), used by most programming languages. To be able to include special characters such as the quotation mark itself, newline characters, or non-printable characters, [[Escape character|escape sequence]]s are often available, usually prefixed with the [[backslash]] character (ASCII 0x5C).
* மேற்கோள் குறிகளால் சூழப்பட்டுள்ளது (ASCII 0x22 இரட்டை மேற்கோள் "str" ​​அல்லது ASCII 0x27 ஒற்றை மேற்கோள் 'str'), பெரும்பாலான நிரலாக்க மொழிகளால் பயன்படுத்தப்படுகிறது. மேற்கோள் குறி, புதிய வரி எழுத்துக்கள் அல்லது அச்சிட முடியாத எழுத்துக்கள் போன்ற சிறப்பு எழுத்துக்களைச் சேர்க்க, தப்பிக்கும் வரிசைகள் பெரும்பாலும் கிடைக்கின்றன, பொதுவாக பின்சாய்வு எழுத்துடன் (ASCII 0x5C) முன்னொட்டாக இருக்கும்.
* Terminated by a [[newline]] sequence, for example in Windows [[INI file]]s.
* விண்டோஸ் INI கோப்புகளில், ஒரு புதிய வரி வரிசை மூலம் நிறுத்தப்பட்டது.
 
== Non-text strings ==
== உரை அல்லாத சரங்கள் ==
While character strings are very common uses of strings, a string in computer science may refer generically to any sequence of homogeneously typed data. A [[bit string]] or [[byte string]], for example, may be used to represent non-textual [[binary data]] retrieved from a communications medium. This data may or may not be represented by a string-specific datatype, depending on the needs of the application, the desire of the programmer, and the capabilities of the programming language being used. If the programming language's string implementation is not [[8-bit clean]], data corruption may ensue.
எழுத்துச்சரங்கள் சரங்களின் மிகவும் பொதுவான பயன்பாடுகள் என்றாலும், கணினி அறிவியலில் ஒரு சரம் பொதுவாக ஒரே மாதிரியாக தட்டச்சு செய்யப்பட்ட தரவின் எந்த வரிசையையும் குறிக்கலாம். ஒரு பிட் சரம் அல்லது பைட் சரம், எடுத்துக்காட்டாக, தகவல்தொடர்பு ஊடகத்திலிருந்து பெறப்பட்ட உரை அல்லாத பைனரி தரவைக் குறிக்கப் பயன்படுத்தப்படலாம். பயன்பாட்டின் தேவைகள், புரோகிராமரின் விருப்பம் மற்றும் பயன்படுத்தப்படும் நிரலாக்க மொழியின் திறன்களைப் பொறுத்து இந்தத் தரவு சரம்-குறிப்பிட்ட தரவு வகையால் குறிப்பிடப்படலாம் அல்லது குறிப்பிடப்படாமல் இருக்கலாம். நிரலாக்க மொழியின் சரம் செயலாக்கம் 8-பிட் சுத்தமாக இல்லை என்றால், தரவு சிதைவு ஏற்படலாம்.
 
C programmers draw a sharp distinction between a "string", aka a "string of characters", which by definition is always null terminated, vs. a "byte string" or "pseudo string" which may be stored in the same array but is often not null terminated.
சி புரோகிராமர்கள் ஒரு "சரம்", அல்லது "எழுத்துகளின் சரம்" ஆகியவற்றுக்கு இடையே கூர்மையான வேறுபாட்டைக் காட்டுகின்றனர், இது வரையறையின்படி எப்போதும் பூஜ்யமாக நிறுத்தப்படும், எதிராக ஒரு "பைட் சரம்" அல்லது "போலி சரம்" அதே வரிசையில் சேமிக்கப்படலாம். பெரும்பாலும் பூஜ்யமாக நிறுத்தப்படுவதில்லை. அத்தகைய "பைட் சரத்தில்" C சரம் கையாளுதல் செயல்பாடுகளைப் பயன்படுத்துவது பெரும்பாலும் வேலை செய்வது போல் தோன்றுகிறது, ஆனால் பின்னர் பாதுகாப்பு சிக்கல்களுக்கு வழிவகுக்கிறது.
Using [[C string handling]] functions on such a "byte string" often seems to work, but later leads to [[#Security concerns|security problems]].<ref>
[https://www.sudo.ws/todd/papers/strlcpy.html "strlcpy and strlcat - consistent, safe, string copy and concatenation."] {{webarchive|url=https://web.archive.org/web/20160313163321/https://www.sudo.ws/todd/papers/strlcpy.html |date=2016-03-13 }}
</ref><ref>
[http://udel.edu/~pconrad/UnixAtUD/strcpy.html "A rant about strcpy, strncpy and strlcpy."] {{webarchive|url=https://web.archive.org/web/20160229080205/http://udel.edu/~pconrad/UnixAtUD/strcpy.html |date=2016-02-29 }}
</ref><ref>
Keith Thompson.
"No, strncpy() is not a "safer" strcpy()".
2012.
</ref>
 
== String processing algorithms ==
== சரம் செயலாக்க அல்காரிதம்கள் ==
{{redirect|Stringology|the physical theory|String theory}}
There are many [[algorithm]]s for processing strings, each with various trade-offs. Competing algorithms can be [[Analysis of algorithms|analyzed]] with respect to run time, storage requirements, and so forth. The name '''stringology''' was coined in 1984 by computer scientist [[Zvi Galil]] for the theory of algorithms and data structures used for string processing.<ref>{{cite web|url=http://www.stringology.org/|title=The Prague Stringology Club|work=stringology.org|access-date=23 May 2015|url-status=live|archive-url=https://web.archive.org/web/20150601001757/http://www.stringology.org/|archive-date=1 June 2015}}</ref><ref>{{cite web |last1=Evarts |first1=Holly |title=Former Dean Zvi Galil Named a Top 10 Most Influential Computer Scientist in the Past Decade |url=https://www.engineering.columbia.edu/news/zvi-galil-top-10-computer-scientist |website=Columbia Engineering |language=en |date=18 March 2021 |quote=He invented the terms 'stringology,' which is a subfield of string algorithms,}}</ref><ref>{{cite book |last1=Crochemore |first1=Maxime |title=Jewels of stringology |date=2002 |___location=Singapore |isbn=981-02-4782-6 |page=v |quote=The term stringology is a popular nickname for string algorithms as well as for text algorithms.}}</ref>
சரங்களைச் செயலாக்குவதற்கு பல வழிமுறைகள் உள்ளன, ஒவ்வொன்றும் பல்வேறு வர்த்தக-ஆஃப்களுடன். இயங்கும் நேரம், சேமிப்பகத் தேவைகள் மற்றும் பலவற்றைப் பொறுத்து போட்டியிடும் அல்காரிதம்களை பகுப்பாய்வு செய்யலாம். 1984 ஆம் ஆண்டில் கணினி விஞ்ஞானி Zvi Galil என்பவரால் stringology என்ற பெயர் வார்ப்பு செயலாக்கத்திற்குப் பயன்படுத்தப்படும் வழிமுறைகள் மற்றும் தரவு கட்டமைப்புகளின் கோட்பாட்டிற்காக உருவாக்கப்பட்டது.
 
Some categories of algorithms include:
சில வகை அல்காரிதம்கள் பின்வருமாறு கொடுக்கப்பட்ட சப்ஸ்ட்ரிங் அல்லது பேட்டர்னைக் கண்டறிவதற்கான சரம் தேடல் அல்காரிதம்கள்
* [[String searching algorithm]]s for finding a given substring or pattern
*சரம் கையாளுதல் அல்காரிதம்கள் வரிசையாக்க வழிமுறைகள் வழக்கமான வெளிப்பாடு அல்காரிதம்கள் ஒரு சரத்தை பாகுபடுத்துதல் வரிசை சுரங்கம்
* [[String manipulation algorithm]]s
* [[Sorting algorithm]]s
* [[Regular expression]] algorithms
* [[Parser|Parsing]] a string
* [[Sequence mining]]
 
Advanced string algorithms often employ complex mechanisms and data structures, among them [[suffix tree]]s and [[finite-state machine]]s.
மேம்பட்ட சரம் வழிமுறைகள் பெரும்பாலும் சிக்கலான வழிமுறைகள் மற்றும் தரவு கட்டமைப்புகளைப் பயன்படுத்துகின்றன, அவற்றுள் பின்னொட்டு மரங்கள் மற்றும் வரையறுக்கப்பட்ட-நிலை இயந்திரங்கள்.
 
== Character string-oriented languages and utilities ==
== எழுத்துச் சரம் சார்ந்த மொழிகள் மற்றும் பயன்பாடுகள்எழுத்துச் சரங்கள் மிகவும் பயனுள்ள தரவு வகையாகும், சரம் செயலாக்க பயன்பாடுகளை எளிதாக எழுதுவதற்கு பல மொழிகள் வடிவமைக்கப்பட்டுள்ளன. எடுத்துக்காட்டுகளில் பின்வரும் மொழிகள் அடங்கும்: ==
Character strings are such a useful datatype that several languages have been designed in order to make string processing applications easy to write. Examples include the following languages:
* [[AWK]]
* [[Icon (programming language)|Icon]]
Line 167 ⟶ 232:
* [[TTM (programming language)|TTM]]
 
Many [[Unix]] utilities perform simple string manipulations and can be used to easily program some powerful string processing algorithms. Files and finite streams may be viewed as strings.
பல யுனிக்ஸ் பயன்பாடுகள் எளிய சரம் கையாளுதல்களைச் செய்கின்றன மற்றும் சில சக்திவாய்ந்த சரம் செயலாக்க வழிமுறைகளை எளிதாக நிரல் செய்ய பயன்படுத்தப்படலாம். கோப்புகள் மற்றும் வரையறுக்கப்பட்ட ஸ்ட்ரீம்கள் சரங்களாகப் பார்க்கப்படலாம்.
 
Some [[application programming interface|API]]s like [[Multimedia Control Interface]], [[embedded SQL]] or [[printf]] use strings to hold commands that will be interpreted.
மல்டிமீடியா கன்ட்ரோல் இன்டர்ஃபேஸ், உட்பொதிக்கப்பட்ட SQL அல்லது printf போன்ற சில APIகள் விளக்கப்படும் கட்டளைகளை வைத்திருக்க சரங்களைப் பயன்படுத்துகின்றன.
 
Many [[scripting programming language]]s, including Perl, [[Python (programming language)|Python]], Ruby, and Tcl employ [[regular expression]]s to facilitate text operations. Perl is particularly noted for its regular expression use,<ref>{{cite web|url=http://cslibrary.stanford.edu/108/EssentialPerl.html#re|title=Essential Perl|quote=Perl's most famous strength is in string manipulation with regular expressions.|url-status=live|archive-url=https://web.archive.org/web/20120421014328/http://cslibrary.stanford.edu/108/EssentialPerl.html#re|archive-date=2012-04-21}}</ref> and many other languages and applications implement [[Perl Compatible Regular Expressions|Perl compatible regular expression]]s.
Perl, Python, Ruby மற்றும் Tcl உள்ளிட்ட பல ஸ்கிரிப்டிங் நிரலாக்க மொழிகள் உரை செயல்பாடுகளை எளிதாக்க வழக்கமான வெளிப்பாடுகளைப் பயன்படுத்துகின்றன. பெர்ல் அதன் வழக்கமான வெளிப்பாடு பயன்பாட்டிற்காக குறிப்பாக குறிப்பிடப்படுகிறது, மேலும் பல மொழிகள் மற்றும் பயன்பாடுகள் பெர்ல் இணக்கமான வழக்கமான வெளிப்பாடுகளை செயல்படுத்துகின்றன.
 
Some languages such as Perl and Ruby support [[string interpolation]], which permits arbitrary expressions to be evaluated and included in string literals.
பெர்ல் மற்றும் ரூபி போன்ற சில மொழிகள் சரம் இடைக்கணிப்பை ஆதரிக்கின்றன, இது தன்னிச்சையான வெளிப்பாடுகளை மதிப்பீடு செய்து சரம் எழுத்துக்களில் சேர்க்க அனுமதிக்கிறது.
 
== Character string functions ==
== எழுத்து சரம் செயல்பாடுகள் ==
{{See also|Comparison of programming languages (string functions)}}
 
[[String function]]s are used to create strings or change the contents of a mutable string. They also are used to query information about a string. The set of functions and their names varies depending on the [[programming language|computer programming language]].
சரங்களை உருவாக்க அல்லது மாற்றக்கூடிய சரத்தின் உள்ளடக்கங்களை மாற்ற சரம் செயல்பாடுகள் பயன்படுத்தப்படுகின்றன. ஒரு சரம் பற்றிய தகவலை வினவவும் அவை பயன்படுத்தப்படுகின்றன. கணினி நிரலாக்க மொழியைப் பொறுத்து செயல்பாடுகளின் தொகுப்பு மற்றும் அவற்றின் பெயர்கள் மாறுபடும்.
 
The most basic example of a string function is the [[string length]] function – the function that returns the length of a string (not counting any terminator characters or any of the string's internal structural information) and does not modify the string. This function is often named <code>[[comparison of programming languages (string functions)#length |length]]</code> or <code>len</code>. For example, <code>length("hello world")</code> would return 11. Another common function is [[concatenation]], where a new string is created by appending two strings, often this is the + addition operator.
ஸ்ட்ரிங் செயல்பாட்டின் மிக அடிப்படையான உதாரணம் ஸ்ட்ரிங் நீளம் சார்பு - சரத்தின் நீளத்தை வழங்கும் செயல்பாடு (எந்த டெர்மினேட்டர் எழுத்துக்களையும் அல்லது சரத்தின் உள் கட்டமைப்புத் தகவலையும் கணக்கிடாது) மற்றும் சரத்தை மாற்றாது. இந்த செயல்பாடு பெரும்பாலும் நீளம் அல்லது லென் என்று அழைக்கப்படுகிறது. எடுத்துக்காட்டாக, நீளம்("ஹலோ வேர்ல்ட்") 11ஐத் தரும். மற்றொரு பொதுவான செயல்பாடு ஒருங்கிணைப்பு ஆகும், இதில் இரண்டு சரங்களைச் சேர்ப்பதன் மூலம் ஒரு புதிய சரம் உருவாக்கப்படுகிறது, பெரும்பாலும் இது + கூட்டல் ஆபரேட்டர் ஆகும்.
 
Some [[microprocessor]]'s [[instruction set architecture]]s contain direct support for string operations, such as block copy (e.g. In [[intel x86]]m <code>REPNZ MOVSB</code>).<ref>{{cite web|url=https://docs.oracle.com/cd/E19120-01/open.solaris/817-5477/eoizn/index.html|title=x86 string instructions|url-status=live|archive-url=https://web.archive.org/web/20150327220944/http://docs.oracle.com/cd/E19120-01/open.solaris/817-5477/eoizn/index.html|archive-date=2015-03-27}}</ref>
சில நுண்செயலியின் அறிவுறுத்தல் தொகுப்பு கட்டமைப்புகள் பிளாக் காப்பி (எ.கா. இன்டெல் x86m REPNZ MOVSB ​​இல்) போன்ற சரம் செயல்பாடுகளுக்கு நேரடி ஆதரவைக் கொண்டுள்ளன.
 
== Formal theory ==
== முறையான கோட்பாடு ==
{{See also|Tuple}}
 
Let Σ be a [[finite set]] of distinct, unambiguous symbols (alternatively called characters), called the [[Alphabet (formal languages)|alphabet]]. A '''string''' (or '''word'''<ref>{{cite book |last1=Fletcher |first1=Peter |last2=Hoyle |first2=Hughes |last3=Patty |first3=C. Wayne |year=1991 |title=Foundations of Discrete Mathematics |publisher=PWS-Kent |isbn= 0-53492-373-9 |page=114 |quote=Let Σ be an alphabet. A '''nonempty word over Σ''' is a finite sequence with ___domain ''I<sub>n</sub>'' (for some ''n'' ∈ ℕ) and codomain Σ.}}</ref> or '''expression'''<ref>{{cite book |last=Shoenfield |first=Joseph R. |authorlink=Joseph R. Shoenfield |year=2010 |origyear=1967 |title=Mathematical Logic |edition=Reprint |publisher=CRC Press |isbn=978-156881135-2 |page=2 |quote=Any finite sequence of symbols of a language is called an ''expression'' of that language.}}</ref>) over Σ is any finite [[sequence]] of symbols from Σ.<ref name="partee">{{cite book |author1=Barbara H. Partee |author2=Alice ter Meulen|author2-link=Alice ter Meulen |author3=Robert E. Wall |title=Mathematical Methods in Linguistics |publisher=Kluwer |year=1990}}</ref> For example, if Σ = {0,&nbsp;1}, then ''01011'' is a string over Σ.
Σ என்பது எழுத்துக்கள் எனப்படும் தனித்துவமான, தெளிவற்ற குறியீடுகளின் (மாற்றாக எழுத்துகள் என அழைக்கப்படும்) வரையறுக்கப்பட்ட தொகுப்பாக இருக்கட்டும். Σ க்கு மேலான ஒரு சரம் (அல்லது சொல் அல்லது வெளிப்பாடு) என்பது Σ இலிருந்து வரும் குறியீடுகளின் எந்தவொரு வரையறுக்கப்பட்ட வரிசையாகும். எடுத்துக்காட்டாக, Σ = {0, 1} எனில், 01011 என்பது Σக்கு மேல் உள்ள சரமாகும்.
 
The ''[[length]]'' of a string ''s'' is the number of symbols in ''s'' (the length of the sequence) and can be any [[non-negative integer]]; it is often denoted as |''s''|. The ''[[empty string]]'' is the unique string over Σ of length 0, and is denoted ''ε'' or ''λ''.<ref name="partee"/><ref>{{cite book| author=John E. Hopcroft, Jeffrey D. Ullman| title=Introduction to Automata Theory, Languages, and Computation| year=1979| publisher=Addison-Wesley| isbn=0-201-02988-X| url-access=registration| url=https://archive.org/details/introductiontoau00hopc}} Here: sect.1.1, p.1</ref>
ஒரு சரத்தின் நீளம் s இல் உள்ள குறியீடுகளின் எண்ணிக்கை (வரிசையின் நீளம்) மற்றும் எந்த எதிர்மறையான முழு எண்ணாகவும் இருக்கலாம்; இது பெரும்பாலும் |s| எனக் குறிக்கப்படுகிறது. வெற்று சரம் என்பது Σ நீளம் 0 க்கு மேல் உள்ள தனித்துவமான சரமாகும், மேலும் இது ε அல்லது λ எனக் குறிக்கப்படுகிறது.
 
The set of all strings over Σ of length ''n'' is denoted Σ<sup>''n''</sup>. For example, if Σ = {0, 1}, then Σ<sup>2</sup> = {00, 01, 10, 11}. We have Σ<sup>0</sup> = {ε} for every alphabet Σ.
Σ நீளம் n க்கு மேல் உள்ள அனைத்து சரங்களின் தொகுப்பு Σn எனக் குறிக்கப்படுகிறது. எடுத்துக்காட்டாக, Σ = {0, 1} என்றால், Σ2 = {00, 01, 10, 11}. ஒவ்வொரு எழுத்துக்களுக்கும் Σ0 = {ε} உள்ளது.
 
The set of all strings over Σ of any length is the [[Kleene star|Kleene closure]] of Σ and is denoted Σ<sup>*</sup>. In terms of Σ<sup>''n''</sup>,
எந்த நீளத்தின் Σ க்கு மேல் உள்ள அனைத்து சரங்களின் தொகுப்பானது Σ இன் க்ளீன் மூடல் மற்றும் Σ* எனக் குறிக்கப்படுகிறது. Σn அடிப்படையில்,
:<math>\Sigma^{*} = \bigcup_{n \in \mathbb{N} \cup \{0\}} \Sigma^{n}</math>
For example, if Σ = {0, 1}, then Σ<sup>*</sup> = {ε, 0, 1, 00, 01, 10, 11, 000, 001, 010, 011, ...}. Although the set Σ<sup>*</sup> itself is [[countably infinite]], each element of Σ<sup>*</sup> is a string of finite length.
 
A set of strings over Σ (i.e. any [[subset]] of Σ<sup>*</sup>) is called a ''[[formal language]]'' over Σ. For example, if Σ = {0, 1}, the set of strings with an even number of zeros, {ε, 1, 00, 11, 001, 010, 100, 111, 0000, 0011, 0101, 0110, 1001, 1010, 1100, 1111, ...}, is a formal language over Σ.
Σ
 
=== Concatenation and substrings ===
''[[Concatenation]]'' is an important [[binary operation]] on Σ<sup>*</sup>. For any two strings ''s'' and ''t'' in Σ<sup>*</sup>, their concatenation is defined as the sequence of symbols in ''s'' followed by the sequence of characters in ''t'', and is denoted ''st''. For example, if Σ = {a, b, ..., z}, ''s''&nbsp;=&nbsp;{{code|bear}}, and ''t''&nbsp;=&nbsp;{{code|hug}}, then ''st''&nbsp;=&nbsp;{{code|bearhug}} and ''ts''&nbsp;=&nbsp;{{code|hugbear}}.
 
String concatenation is an [[associative]], but non-[[commutative]] operation. The empty string ε serves as the [[identity element]]; for any string ''s'', ε''s'' = ''s''ε = ''s''. Therefore, the set Σ<sup>*</sup> and the concatenation operation form a [[monoid]], the [[free monoid]] generated by Σ. In addition, the length function defines a [[monoid homomorphism]] from Σ<sup>*</sup> to the non-negative integers (that is, a function <math>L: \Sigma^{*} \mapsto \mathbb{N} \cup \{0\}</math>, such that <math>L(st)=L(s)+L(t)\quad \forall s,t\in\Sigma^*</math>).
=
 
A string ''s'' is said to be a ''[[substring]]'' or ''factor'' of ''t'' if there exist (possibly empty) strings ''u'' and ''v'' such that ''t'' = ''usv''. The [[binary relation|relation]] "is a substring of" defines a [[partial order]] on Σ<sup>*</sup>, the [[least element]] of which is the empty string.
 
=== Prefixes and suffixes ===
𝑛
A string ''s'' is said to be a [[Substring#Prefix|prefix]] of ''t'' if there exists a string ''u'' such that ''t'' = ''su''. If ''u'' is nonempty, ''s'' is said to be a ''proper'' prefix of ''t''. Symmetrically, a string ''s'' is said to be a [[Substring#Suffix|suffix]] of ''t'' if there exists a string ''u'' such that ''t'' = ''us''. If ''u'' is nonempty, ''s'' is said to be a ''proper'' suffix of ''t''. Suffixes and prefixes are substrings of ''t''. Both the relations "is a prefix of" and "is a suffix of" are [[prefix order]]s.
 
=== Reversal ===
The reverse of a string is a string with the same symbols but in reverse order. For example, if ''s'' = abc (where a, b, and c are symbols of the alphabet), then the reverse of ''s'' is cba. A string that is the reverse of itself (e.g., ''s'' = madam) is called a [[palindrome#Computation theory|palindrome]], which also includes the empty string and all strings of length 1.
 
=== Rotations ===
𝑁
A string ''s'' = ''uv'' is said to be a rotation of ''t'' if ''t'' = ''vu''. For example, if Σ = {0, 1} the string 0011001 is a rotation of 0100110, where ''u'' = 00110 and ''v'' = 01. As another example, the string abc has three different rotations, viz. abc itself (with ''u''=abc, ''v''=ε), bca (with ''u''=bc, ''v''=a), and cab (with ''u''=c, ''v''=ab).
 
=== Lexicographical ordering ===
It is often useful to define an [[order theory|ordering]] on a set of strings. If the alphabet Σ has a [[total order]] (cf. [[alphabetical order]]) one can define a total order on Σ<sup>*</sup> called [[lexicographical order]]. The lexicographical order is [[total order|total]] if the alphabetical order is, but is not [[well-founded]] for any nontrivial alphabet, even if the alphabetical order is. For example, if Σ = {0, 1} and 0 < 1, then the lexicographical order on Σ<sup>*</sup> includes the relationships ε < 0 < 00 < 000 < ... < 0001 < ... < 001 < ... < 01 < 010 < ... < 011 < 0110 < ... < 01111 < ... < 1 < 10 < 100 < ... < 101 < ... < 111 < ... < 1111 < ... < 11111 ... With respect to this ordering, e.g. the infinite set { 1, 01, 001, 0001, 00001, 000001, ... } has no minimal element.
 
See [[Shortlex]] for an alternative string ordering that preserves well-foundedness.
{
For the example alphabet, the shortlex order is ε < 0 < 1 < 00 < 01 < 10 < 11 < 000 < 001 < 010 < 011 < 100 < 101 < 0110 < 111 < 0000 < 0001 < 0010 < 0011 < ... < 1111 < 00000 < 00001 ...
 
=== String operations ===
0
A number of additional operations on strings commonly occur in the formal theory. These are given in the article on [[string operations]].
 
=== Topology ===
}
 
Σ
 
𝑛
 
எடுத்துக்காட்டாக, Σ = {0, 1} என்றால், Σ* = {ε, 0, 1, 00, 01, 10, 11, 000, 001, 010, 011, ...}. Σ* ஆனது எண்ணிலடங்காத அளவாக இருந்தாலும், Σ* இன் ஒவ்வொரு உறுப்பும் வரையறுக்கப்பட்ட நீளத்தின் சரம் ஆகும்.
 
Σக்கு மேல் உள்ள சரங்களின் தொகுப்பு (அதாவது Σ* இன் ஏதேனும் துணைக்குழு) Σக்கு மேல் முறையான மொழி எனப்படும். எடுத்துக்காட்டாக, Σ = {0, 1} எனில், பூஜ்ஜியங்களின் இரட்டை எண் கொண்ட சரங்களின் தொகுப்பு, {ε, 1, 00, 11, 001, 010, 100, 111, 0000, 0011, 0101, 0110, 1001, 1010, 1100, 1111, ...}, Σ ஐ விட முறையான மொழி.
 
=== ஒருங்கிணைப்பு மற்றும் துணைச்சரங்கள் ===
இணைத்தல் என்பது Σ* இல் ஒரு முக்கியமான பைனரி செயல்பாடாகும். Σ* இல் உள்ள எந்த இரண்டு சரங்களுக்கும் s மற்றும் t, அவற்றின் ஒருங்கிணைப்பு s இல் உள்ள குறியீடுகளின் வரிசையைத் தொடர்ந்து t இல் உள்ள எழுத்துக்களின் வரிசையாக வரையறுக்கப்படுகிறது, மேலும் இது st எனக் குறிக்கப்படுகிறது. எடுத்துக்காட்டாக, Σ = {a, b, ..., z}, s = பியர், மற்றும் t = கட்டிக்கொண்டால், st = bearhug and ts = hugbear.
 
சரம் இணைப்பு என்பது ஒரு துணை, ஆனால் பரிமாற்றம் அல்லாத செயல்பாடு. வெற்று சரம் ε அடையாள உறுப்பாக செயல்படுகிறது; எந்த சரத்திற்கும் s, εs = sε = s. எனவே, தொகுப்பு Σ* மற்றும் ஒருங்கிணைப்பு செயல்பாடு ஒரு மோனோயிடை உருவாக்குகிறது, இது Σ ஆல் உருவாக்கப்பட்ட இலவச மோனாய்டு ஆகும். கூடுதலாக, நீளம் சார்பு ஒரு மோனோயிட் ஹோமோமார்பிஸத்தை Σ* இலிருந்து எதிர்மறை அல்லாத முழு எண்கள் வரை வரையறுக்கிறது (அதாவது ஒரு செயல்பாடு
 
𝐿
 
<nowiki>:</nowiki>
 
Σ
 
 
 
𝑁
 
 
{
 
0
 
}
 
, அதுபோல்
 
𝐿
 
(
 
𝑠
 
𝑡
 
)
 
=
 
𝐿
 
(
 
𝑠
 
)
 
+
 
𝐿
 
(
 
𝑡
 
)
 
 
𝑠
 
,
 
𝑡
 
 
Σ
 
 
)
 
ஒரு சரம் s என்பது t = usv போன்ற u மற்றும் v ஆகிய சரங்கள் இருந்தால் (ஒருவேளை காலியாக இருக்கலாம்) t இன் துணைச்சரம் அல்லது காரணியாகக் கூறப்படுகிறது. "இன் துணைச் சரம்" என்பது Σ* இல் ஒரு பகுதி வரிசையை வரையறுக்கிறது, இதில் குறைந்தபட்ச உறுப்பு வெற்று சரம்.
 
=== முன்னொட்டுகள் மற்றும் பின்னொட்டுகள் ===
t = su போன்ற சரம் u இருந்தால் t இன் முன்னொட்டு s என்று கூறப்படுகிறது. நீங்கள் வெறுமையாக இருந்தால், s என்பது t இன் சரியான முன்னொட்டு எனக் கூறப்படுகிறது. சமச்சீராக, t = us என்று ஒரு சரம் u இருந்தால், s என்பது t இன் பின்னொட்டு என்று கூறப்படுகிறது. நீங்கள் காலியாக இருந்தால், s என்பது t இன் சரியான பின்னொட்டு என்று கூறப்படுகிறது. பின்னொட்டுகள் மற்றும் முன்னொட்டுகள் t இன் துணைச்சரங்கள். "இன் முன்னொட்டு" மற்றும் "இன் பின்னொட்டு" ஆகிய இரண்டு உறவுகளும் முன்னொட்டு ஆணைகள்.
 
=== தலைகீழ் ===
சரத்தின் தலைகீழ் அதே குறியீடுகளைக் கொண்ட ஒரு சரம் ஆனால் தலைகீழ் வரிசையில் உள்ளது. எடுத்துக்காட்டாக, s = abc (இங்கு a, b மற்றும் c ஆகியவை எழுத்துக்களின் குறியீடுகள்) எனில், s இன் தலைகீழ் cba ஆகும். தானே தலைகீழாக இருக்கும் ஒரு சரம் (எ.கா., s = மேடம்) ஒரு பாலிண்ட்ரோம் என்று அழைக்கப்படுகிறது, இதில் வெற்று சரம் மற்றும் 1 நீளமுள்ள அனைத்து சரங்களும் அடங்கும்.
 
=== சுழற்சிகள் ===
ஒரு சரம் s = uv t = vu என்றால் t இன் சுழற்சி என்று கூறப்படுகிறது. எடுத்துக்காட்டாக, Σ = {0, 1} சரம் 0011001 என்பது 0100110 இன் சுழற்சியாகும், இங்கு u = 00110 மற்றும் v = 01. மற்றொரு எடுத்துக்காட்டு, சரம் abc மூன்று வெவ்வேறு சுழற்சிகளைக் கொண்டுள்ளது, அதாவது. abc தானே (u=abc, v=ε உடன்), bca (u=bc, v=a உடன்), மற்றும் cab (u=c, v=ab உடன்).
 
=== அகராதி வரிசைப்படுத்துதல் ===
சரங்களின் தொகுப்பில் ஒரு வரிசையை வரையறுப்பது பெரும்பாலும் பயனுள்ளதாக இருக்கும். Σ எழுத்துக்கள் மொத்த வரிசையைக் கொண்டிருந்தால் (cf. அகரவரிசை வரிசை) Σ* இல் உள்ள மொத்த வரிசையை லெக்சிகோகிராஃபிக்கல் ஆர்டர் என அழைக்கப்படும் ஒருவர் வரையறுக்கலாம். அகரவரிசை வரிசையாக இருந்தால், அகராதி வரிசை மொத்தமாக இருக்கும், ஆனால் அகரவரிசை வரிசையாக இருந்தாலும், எந்த அற்பமான அல்லாத எழுத்துக்களுக்கும் சரியாக நிறுவப்படவில்லை. எடுத்துக்காட்டாக, Σ = {0, 1} மற்றும் 0 <1 எனில், Σ* இல் உள்ள அகராதி வரிசையில் ε < 0 < 00 < 000 < ... < 0001 < ... < 001 < ... < 01 < 010 < ... < 011 < 0110 < ... < 01111 < ... < 1 < 10 < 100 < ... < 101 < ... < 111 < ... < 1111 < ... < 11111 ... இந்த உத்தரவைப் பொறுத்தவரை, எ.கா. எல்லையற்ற தொகுப்பில் {1, 01, 001, 0001, 00001, 000001, ... } குறைந்தபட்ச உறுப்பு இல்லை.
 
நன்கு அடித்தளத்தை பாதுகாக்கும் மாற்று சரம் வரிசைப்படுத்தலுக்கு Shortlex ஐ பார்க்கவும். எடுத்துக்காட்டு எழுத்துக்களுக்கு, ஷார்ட்லெக்ஸ் வரிசை ε < 0 < 1 < 00 < 01 < 10 < 11 < 000 < 001 < 010 < 011 < 100 < 101 < 0110 < 111 < 0000 < 0001 < 0010 < 0010 < 1111 < 00000 < 00001 ...
 
=== சரம் செயல்பாடுகள் ===
சரங்களில் பல கூடுதல் செயல்பாடுகள் பொதுவாக முறையான கோட்பாட்டில் நிகழ்கின்றன. சரம் செயல்பாடுகள் பற்றிய கட்டுரையில் இவை கொடுக்கப்பட்டுள்ளன.
 
=== கட்டமைப்பியல் ===
[[File:Hamming distance 3 bit binary.svg|thumb|150px|(Hyper)cube of binary strings of length 3]]
Strings admit the following interpretation as nodes on a graph, where ''k'' is the number of symbols in Σ:
சரங்கள் பின்வரும் விளக்கத்தை ஒரு வரைபடத்தில் முனைகளாக ஒப்புக்கொள்கின்றன, இங்கு k என்பது Σ இல் உள்ள குறியீடுகளின் எண்ணிக்கை:
* Fixed-length strings of length ''n'' can be viewed as the integer locations in an ''n''-dimensional [[hypercube]] with sides of length ''k''-1.
 
* Variable-length strings (of finite length) can be viewed as nodes on a [[k-ary tree|perfect ''k''-ary tree]].
நீளம் n இன் நிலையான-நீள சரங்களை நீளம் k-1 பக்கங்களைக் கொண்ட n-பரிமாண ஹைப்பர்க்யூப்பில் முழு எண் இருப்பிடங்களாகக் காணலாம்.
* [[Infinite string]]s (otherwise not considered here) can be viewed as infinite paths on a ''k''-node [[complete graph]].
 
மாறி-நீள சரங்களை (வரையறுக்கப்பட்ட நீளம்) ஒரு சரியான k-ary மரத்தில் முனைகளாகப் பார்க்கலாம்.
 
முடிவிலா சரங்கள் (இல்லையெனில் இங்கே கருதப்படாது) k-node முழுமையான வரைபடத்தில் எல்லையற்ற பாதைகளாகப் பார்க்கலாம்.
 
நிலையான-நீள சரங்கள் அல்லது மாறி-நீள சரங்களின் தொகுப்பில் உள்ள இயற்கை இடவியல் என்பது தனித்துவமான இடவியல் ஆகும், ஆனால் எல்லையற்ற சரங்களின் தொகுப்பில் உள்ள இயற்கை இடவியல் வரம்பு இடவியல் ஆகும். வரையறுக்கப்பட்ட சரங்கள். இது பி-ஆடிக் எண்கள் மற்றும் கேன்டர் தொகுப்பின் சில கட்டுமானங்களுக்குப் பயன்படுத்தப்படும் கட்டுமானமாகும், மேலும் அதே இடவியலை அளிக்கிறது.
 
டோபோலாஜிகளின் சரம் பிரதிநிதித்துவங்களுக்கிடையேயான ஐசோமார்பிஸங்களை, சொற்களஞ்சிய ரீதியாக குறைந்தபட்ச சரம் சுழற்சியின்படி இயல்பாக்குவதன் மூலம் கண்டறியலாம்.
 
== மேலும் பார்க்கவும் ==
 
== பைனரி-சேஃப் — சரம் கையாளும் செயல்பாடுகளின் பண்பு, அவற்றின் உள்ளீட்டை மூல தரவு ஸ்ட்ரீமாகக் கருதுகிறது ==
 
== பிட் அணிவரிசை - பைனரி இலக்கங்களின் சரம் ==
 
== சி சரம் கையாளுதல் - சி சரம் கையாளுதல் பற்றிய கண்ணோட்டம் ==
 
== C++ சரம் கையாளுதல் — C++ சரம் கையாளுதலின் மேலோட்டம் ==
 
== நிரலாக்க மொழிகளின் ஒப்பீடு (சரம் செயல்பாடுகள்) ==
 
== இணைப்பு சரம் - இணைப்பைத் தொடங்க இயக்கிக்கு அனுப்பப்பட்டது (எ.கா. தரவுத்தளத்திற்கு) ==
 
== வெற்று சரம் — அதன் பண்புகள் மற்றும் நிரலாக்க மொழிகளில் பிரதிநிதித்துவம் ==
 
The natural topology on the set of fixed-length strings or variable-length strings is the discrete topology, but the natural topology on the set of infinite strings is the [[limit topology]], viewing the set of infinite strings as the [[inverse limit]] of the sets of finite strings. This is the construction used for the [[p-adic|''p''-adic numbers]] and some constructions of the [[Cantor set]], and yields the same topology.
== Incompressible string — எந்த வழிமுறையாலும் சுருக்க முடியாத சரம் ==
 
[[Isomorphism]]s between string representations of topologies can be found by normalizing according to the [[lexicographically minimal string rotation]].
== கயிறு (தரவு அமைப்பு) - நீண்ட சரங்களை திறமையாக கையாளும் ஒரு தரவு அமைப்பு ==
 
== See also ==
== சரம் மெட்ரிக் - சரங்களுக்கு இடையே உள்ள ஒற்றுமை பற்றிய கருத்துக்கள் ==
* [[Binary-safe]] — a property of string manipulating functions treating their input as raw data stream
* [[Bit array]] — a string of binary digits
* [[C string handling]] — overview of C string handling
* [[C++ string handling]] — overview of C++ string handling
* [[Comparison of programming languages (string functions)]]
* [[Connection string]] — passed to a driver to initiate a connection (e.g., to a database)
* [[Empty string]] — its properties and representation in programming languages
* [[Incompressible string]] — a string that cannot be compressed by any algorithm
* [[Rope (data structure)]] — a data structure for efficiently manipulating long strings
* [[String metric]] — notions of similarity between strings
 
== References ==
== குறிப்புகள் ==
{{Reflist}}