Comparison of programming languages (strings)

This comparison of programming languages (strings) compares the features of string data structures or text-string processing for over 52 various computer programming languages.

Concatenation

Different languages use different symbols for the concatenation operator. Many languages use the "+" symbol, though several deviate from this.

Common variants

Operator Languages
+ ALGOL 68, BASIC, C++, C#, Cobra, Dart, Eiffel, F#, Go, Java, JavaScript, Object Pascal, Objective-C, Pascal, Python, Ruby, Rust, Scala, Swift, Turing, Windows PowerShell, Ya
++ Erlang, Haskell
$+ mIRC scripting language
& Ada, AppleScript, COBOL (for literals only), Curl, Excel, FreeBASIC, HyperTalk, Nim, Seed7, VHDL, Visual Basic, Visual Basic .NET
concatenate Common Lisp
. Autohotkey, Maple (up to version 5), Perl, PHP
~ D, Raku, Symfony (Expression Language component)
|| Icon, Maple (from version 6), PL/I, Rexx, Standard SQL
<> Mathematica, Wolfram Language, Elixir
.. Lua
: Pick Basic
, APL, J, Smalltalk
^ F#, OCaml, rc, Standard ML
// Fortran
* Julia

Unique variants

  • AWK uses the empty string: two expressions adjacent to each other are concatenated. This is called juxtaposition. Unix shells have a similar syntax. Rexx uses this syntax for concatenation including an intervening space.
  • C (along with Python) allows juxtaposition for string literals, however, for strings stored as character arrays, the strcat function must be used.
  • COBOL uses the STRING statement to concatenate string variables.
  • MATLAB and Octave use the syntax "[x y]" to concatenate x and y.
  • Visual Basic and Visual Basic .NET can also use the "+" sign but at the risk of ambiguity if a string representing a number and a number are together.
  • Microsoft Excel allows both "&" and the function "=CONCATENATE(X,Y)".
  • Rust has the concat! macro and the format! macro, of which the latter is the most prevalent throughout the documentation and examples.

String literals

This section compares styles for declaring a string literal.

Quoted interpolated

An expression is "interpolated" into a string when the compiler/interpreter evaluates it and inserts the result in its place.

Syntax Language(s)
$"hello, {name}" C#, Visual Basic .NET
"Hello, $name!" Bourne shell, Dart, Perl, PHP, Windows PowerShell
qq(Hello, $name!) Perl (alternate)
"Hello, {$name}!" PHP (alternate)
"Hello, #{name}!" CoffeeScript, Ruby, Elixir
%Q(Hello, #{name}!) Ruby (alternate)
(format nil "Hello, ~A" name) Common Lisp
`Hello, ${name}!` JavaScript (ECMAScript 6)
"Hello, \(name)!" Swift
f'Hello, {name}!' Python

Escaped quotes

"Escaped" quotes means that a 'flag' symbol is used to warn that the character after the flag is used in the string rather than ending the string.

Syntax Language(s)
"I said \"Hello, world!\"" C, C++, C#, D, Dart, F#, Java, JavaScript, Mathematica, Ocaml, Perl, PHP, Python, Rust, Swift, Wolfram Language, Ya
'I said \'Hello, world!\'' CoffeeScript, Dart (alternate), JavaScript (alternate), Python (alternate)
"I said `"Hello, world!`"" Windows Powershell
"I said ^"Hello, world!^"" REBOL
{I said "Hello, world!"} REBOL (alternate)
"I said, %"Hello, World!%"" Eiffel
!"I said \"Hello, world!\"" FreeBASIC
r#"I said "Hello, world!""# Rust (alternate)
R"("I said "Hello, world!")" C++ (alternate)

Dual quoting

"Dual quoting" means that whenever a quote is used in a string, it is used twice, and one of them is discarded and the single quote is then used within the string.

Syntax Language(s)
"I said ""Hello, world!""" Ada, ALGOL 68, COBOL, Excel, Fortran, FreeBASIC, Visual Basic (.NET)
'I said ''Hello, world!''' APL, COBOL, Fortran, Object Pascal, Pascal, rc, Smalltalk, SQL

Quoted raw

"Raw" means the compiler treats every character within the literal exactly as written, without processing any escapes or interpolations.

Syntax Language(s)
'Hello, world!' APL, Bourne shell, Fortran, Object Pascal, Pascal, Perl, PHP, Pick Basic, Ruby, Smalltalk, Windows PowerShell
q(Hello, world!) Perl (alternate)
%q(Hello, world!) Ruby (alternate)
R"(Hello, world!)" C++11
@"Hello, world!" C#, F#
r"Hello, world!" Cobra, D, Dart, Python, Rust
r'Hello, world!' Dart (alternate)
"Hello, world!" Cobol, FreeBASIC, Pick Basic
`Hello, world!` D, Go
raw"Hello, world!" Scala
String.raw`Hello, World!` JavaScript (ECMAScript 6) [1]

Multiline string

Many languages have a syntax specifically intended for strings with multiple lines. In some of these languages, this syntax is a here document or "heredoc": A token representing the string is put in the middle of a line of code, but the code continues after the starting token and the string's content doesn't appear until the next line. In other languages, the string's content starts immediately after the starting token and the code continues after the string literal's terminator.

Syntax Here
document
Language(s)
<<EOF
I have a lot of things to say
and so little time to say them
EOF
Yes Bourne shell, Perl, Ruby
<<<EOF
I have a lot of things to say
and so little time to say them
EOF
Yes PHP
@"
I have a lot of things to say
and so little time to say them
"@
No Windows Powershell
"[
I have a lot of things to say
and so little time to say them
]"
No Eiffel
"""
I have a lot of things to say
and so little time to say them
"""
No CoffeeScript, Dart, Groovy, Kotlin, Python, Swift
"
I have a lot of things to say
and so little time to say them
"
No Common Lisp (all strings are multiline), Rust (all strings are multiline), Visual Basic .NET (all strings are multiline)
R"(
I have a lot of things to say
and so little time to say them
)"
No C++
r"
I have a lot of things to say
and so little time to say them
"
No Rust
[[
I have a lot of things to say
and so little time to say them
]]
No Lua
`
I have a lot of things to say
and so little time to say them
`
No JavaScript (ECMAScript 6)

Unique quoting variants

Syntax Variant name Language(s)
13HHello, world! Hollerith notation Fortran 66
(indented with whitespace) Indented with whitespace and newlines YAML

Notes

1. ^ String.raw`` still processes string interpolation.

References

1. ^ https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw

Read other articles:

artikel ini perlu dirapikan agar memenuhi standar Wikipedia. Tidak ada alasan yang diberikan. Silakan kembangkan artikel ini semampu Anda. Merapikan artikel dapat dilakukan dengan wikifikasi atau membagi artikel ke paragraf-paragraf. Jika sudah dirapikan, silakan hapus templat ini. (Pelajari cara dan kapan saatnya untuk menghapus pesan templat ini) Artikel ini tidak memiliki referensi atau sumber tepercaya sehingga isinya tidak bisa dipastikan. Tolong bantu perbaiki artikel ini dengan menamba...

 

La CourneuveNegaraPrancisArondisemenSaint-DenisKantonLa CourneuveAntarkomuneCommunautéd'agglomérationPlaine CommuneKode INSEE/pos93027 /  La Courneuve merupakan sebuah komune di pinggiran timurlaut Paris, Prancis. Terletak 8.3 km (5.2 mil) dari pusat kota Paris. Dikenal untuk banyaknya bangunan perumahan tinggi, dihuni oleh imigran dan keturunannya. Sejarah Sejarah La Courneuve dimulai dengan penyerangan suku Eropa dan penaklukan wilayah oleh Romawi. Selama Era Pertengahan, wilaya...

 

Halaman ini berisi artikel tentang permainan video tahun 2020 yang akan datang. Untuk judul keempat dari seri Crash Bandicoot, lihat Crash Bandicoot: The Wrath of Cortex. Crash Bandicoot 4: It's About Time Seni sampul, memerankan Coco (kiri) dan Crash (tengah)Publikasi2 Oktober 2020GenrePlatformBahasa Daftar Ceko, Inggris, Jepang, Prancis, Serbia, Spanyol dan Wales 60 Karakteristik teknisPlatformPlayStation 4, Xbox One, Windows, PlayStation 5, Xbox Series X dan S dan Nintendo Switch MesinUnr...

Синелобый амазон Научная классификация Домен:ЭукариотыЦарство:ЖивотныеПодцарство:ЭуметазоиБез ранга:Двусторонне-симметричныеБез ранга:ВторичноротыеТип:ХордовыеПодтип:ПозвоночныеИнфратип:ЧелюстноротыеНадкласс:ЧетвероногиеКлада:АмниотыКлада:ЗавропсидыКласс:Пт�...

 

Ini adalah nama Maluku, Ambon, marganya adalah Lisapaly Johanna E. LisapalyS.H., M.Si. Pelaksana Tugas Wali Kota KupangMasa jabatan26 Oktober 2016 – 11 Februari 2017PresidenJoko WidodoGubernurFrans Lebu RayaPendahuluJonas SaleanPenggantiBernadus BenuPenjabat Sekda Nusa Tenggara TimurMasa jabatan21 Oktober 2022 – 24 Mei 2023PresidenJoko WidodoGubernurViktor Bungtilu LaiskodatPendahuluDomu WarandoyPenggantiDamianus Lana Informasi pribadiLahirJohanna Engeline Lisapaly10 Jan...

 

追晉陸軍二級上將趙家驤將軍个人资料出生1910年 大清河南省衛輝府汲縣逝世1958年8月23日(1958歲—08—23)(47—48歲) † 中華民國福建省金門縣国籍 中華民國政党 中國國民黨获奖 青天白日勳章(追贈)军事背景效忠 中華民國服役 國民革命軍 中華民國陸軍服役时间1924年-1958年军衔 二級上將 (追晉)部队四十七師指挥東北剿匪總司令部參謀長陸軍�...

US Supreme Court justice from 1791 to 1793 For other people with the same name, see Thomas Johnson (disambiguation). Thomas JohnsonAssociate Justice of the Supreme Court of the United StatesIn officeSeptember 19, 1791 – January 16, 1793[1]Nominated byGeorge WashingtonPreceded byJohn RutledgeSucceeded byWilliam Paterson1st Governor of MarylandIn officeMarch 21, 1777 – November 12, 1779Preceded byRobert Eden (Royal)Succeeded byThomas Lee2nd Commissioner of the Fede...

 

1974 Canadian film The Apprenticeship of Duddy KravitzTheatrical release posterDirected byTed KotcheffScreenplay byMordecai RichlerStory byLionel Chetwynd (Adaptation)Based onThe Apprenticeship of Duddy Kravitzby Mordecai RichlerProduced byJohn Kemeny[1]StarringRichard DreyfussMicheline LanctôtRandy QuaidJoseph WisemanDenholm ElliottJoe SilverJack WardenCinematographyBrian WestEdited byThom NobleMusic byStanley MyersAndrew PowellProductioncompaniesInternational Cinemedia CenterCanadi...

 

BrussoncomuneBrusson – Veduta LocalizzazioneStato Francia RegioneGrand Est Dipartimento Marna ArrondissementVitry-le-François CantoneSermaize-les-Bains TerritorioCoordinate48°45′N 4°42′E / 48.75°N 4.7°E48.75; 4.7 (Brusson)Coordinate: 48°45′N 4°42′E / 48.75°N 4.7°E48.75; 4.7 (Brusson) Superficie4,9 km² Abitanti218[1] (2009) Densità44,49 ab./km² Altre informazioniCod. postale51300 Fuso orarioUTC+1 Codice INSEE51094...

Separatist dispute Kurdish separatism in IranPJAK fighters in 2012Date1918 (1918) – present (106 years)[9][10](main phase 1943[11] – present[12])LocationIran, Iran-Iraqi Kurdistan border areas For a map, see hereStatus Ongoing Several tribal revolts during 1918–1943 1946 failed attempt to establish the Republic of Mahabad Political crackdown on Kurdish political associations in Iran[13] Ceasefire between Iran and PJAK established in Sept...

 

Cette page contient des caractères spéciaux ou non latins. S’ils s’affichent mal (▯, ?, etc.), consultez la page d’aide Unicode. Pour les articles homonymes, voir Nirvana. Le nirvana[1] (sanskrit IAST : nirvāṇa ; pali : nibbāna) est un concept philosophique de l'hindouisme, du jaïnisme et du bouddhisme qui signifie « extinction » (du feu des passions, de l'ignorance) ou « libération » (du saṃsāra, du cycle des...

 

Cet article concerne Parti conservateur de l'Empire allemand. Pour le parti du royaume de Prusse, voir Parti conservateur (Royaume de Prusse). Membres du groupe parlementaire des conservateurs allemand (de gauche à droite) : Rudolph Wichmann, Otto von Seydewitz, Helmuth von Moltke, Graf Konrad von Kleist-Schmenzin, Otto von Helldorff, Karl Gustav Ackermann. Le Parti conservateur allemand (en allemand : Deutschkonservative Partei) est un parti politique de l'Empire allemand fon...

Washington's 23rd legislative district Washington's 23rd legislative district is one of forty-nine districts in Washington state for representation in the state legislature. The district includes northern Kitsap County and Bainbridge Island.[1] The district's legislators are state senator Drew Hansen and state representatives Tarra Simmons (position 1) and Greg Nance (position 2), all Democrats. See also Washington Redistricting Commission Washington State Legislature Washington Stat...

 

Former Minister of Education of Brazil This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these template messages) This biography of a living person needs additional citations for verification. Please help by adding reliable sources. Contentious material about living persons that is unsourced or poorly sourced must be removed immediately from the article and its talk page, especially if potentially libelous.Find sou...

 

Kingdom in southern India from 1729 to 1949 For other uses, see Travancore (disambiguation). Kingdom of TravancoreThiruvithaamkoor Rajyam1729–1949 Flag Coat of arms Motto: ധർമോസ്മത്ത് കുലദൈവതം Dharmōsmat Kuladaivatam (English: Charity is our household divinity)Anthem: വഞ്ചീശ മംഗളംVancheesha Mangalam (1937–1949)(English:Victory to the Lord of Vanchi) Location of the Kingdom of Travancore (in red) in India (in green)Comm...

Kingston RangeKingston Range, Mojave DesertHighest pointPeakKingston PeakElevation7,323 ft (2,232 m)GeographyKingston RangeLocation of Kingston Range in California[1] CountryUnited StatesStateCaliforniaRegionMojave DesertDistrictSan Bernardino CountyRange coordinates35°47′2.900″N 115°54′7.049″W / 35.78413889°N 115.90195806°W / 35.78413889; -115.90195806Topo mapUSGS Horse Thief Springs The Kingston Range, sometimes called the King...

 

سنباذ المجوسي معلومات شخصية مكان الميلاد نيسابور  الوفاة سنة 756   مدينة الري  مواطنة إيران  الحياة العملية المهنة زعيم روحي  تعديل مصدري - تعديل   سنباذ المجوسي (بالفارسية: سنباد) رجل مجوسي من أهل فارس.[1] كان من أتباع أبي مسلم الخراساني، ولما قتل أبو مسلم ع�...

 

History United States NameLST-973 BuilderBethlehem-Hingham Shipyard, Hingham, Massachusetts Yard number3443[1] Laid down25 November 1944 Launched27 December 1944 Commissioned27 January 1945 Decommissioned24 May 1946 Stricken29 September 1947 Identification Hull symbol: LST-973 Code letters: NKKP Fate Transferred to US Army custody Reinstated in the Naval Register, 6 September 1950 Commissioned6 September 1950 Decommissioned7 November 1951 Stricken20 November 1951 Honors andawards 4 �...

SMA Negeri 18 JakartaInformasiDidirikan1 Oktober 1965 s/d23 Agustus 1966 (SMA Negeri X yang berbakti)[1]24 Agustus 1966[1]JenisSekolah NegeriAkreditasiA[2]Nomor Pokok Sekolah Nasional20100809[3]MaskotBurung ElangKepala SekolahArdiansyah,MpdJurusan atau peminatanMIPA, Bahasa dan IPSRentang kelasX,XI,XII MIPA/IPS/BahasaKurikulumKurikulum 2013AlamatLokasiJalan Warakas I, Tanjung Priok, Jakarta Utara, DKI Jakarta, IndonesiaTel./Faks.+62 21 4353561 / +62 21 435...

 

Garac En arrivant du sud Administration Pays France Région Occitanie Département Haute-Garonne Arrondissement Toulouse Intercommunalité Communauté de communes des Hauts Tolosans Maire Mandat Joël Melac 2020-2026 Code postal 31480 Code commune 31209 Démographie Gentilé Garacois, Garacoises Populationmunicipale 160 hab. (2021 ) Densité 26 hab./km2 Géographie Coordonnées 43° 41′ 32″ nord, 1° 05′ 21″ est Altitude Min. 150 mMax. 274...