Comparison of programming languages (string functions)
Format Languages Format string syntax
associate ( file , string ) ; putf ( file , $ formatstring $ , items ) ALGOL 68 ALGOL
Format ( item , formatstring ) VB
sprintf ( formatstring , items ) Perl , PHP , Raku , Ruby C
item.fmt ( formatstring ) Raku C
io_lib : format ( formatstring , items ) Erlang
sprintf ( outputstring , formatstring , items ) C C
std.string.format ( formatstring , items ) D C
Format ( formatstring , items ) Object Pascal ( Delphi )
fmt.Sprintf ( formatstring , items ) Go C
printf -v outputstring formatstring items Bash shell C
formatstring% ( items ) Python , Ruby C
formatstring .format ( items ) Python .NET
Printf.sprintf formatstring items OCaml , F # C
Text.Printf.printf formatstring items Haskell ( GHC ) C
formatstring printf : items Smalltalk C
String.format ( formatstring , items ) Java C
String.Format ( formatstring , items ) VB .NET , C # , F # .NET
( format formatstring items ) Scheme ( SRFI 28 ) Lisp
( format nil formatstring items ) Common Lisp Lisp
( format formatstring items ) Clojure Lisp
Common string functions ( multi language reference ) -- Format
See also : printf format string Definition format ( formatstring , items ) returns string Description Returns the formatted string representation of one or more items .
String functions are used in computer programming languages to manipulate a string or query information about a string (some do both). Most programming languages that have a string datatype will have some string functions although there may be other low-level ways within each language to handle strings directly. In object-oriented languages, string functions are often implemented as properties and methods of string objects. In functional and list-based languages a string is represented as a list (of character codes), therefore all list-manipulation procedures could be considered string functions. However such languages may implement a subset of explicit string-specific functions as well. For function that manipulate strings, modern object-oriented languages, like C# and Java have immutable strings and return a copy (in newly allocated dynamic memory), while others, like C manipulate the original string unless the programmer copies data to a new string. See for example Concatenation below. The most basic example of a string function is the codice_1 function. This function returns the length of a string literal. Other languages may have string functions with similar or exactly the same syntax or parameters or outcomes. For example, in many languages the length function is usually represented as len(string). The below list of common functions aims to help limit this confusion.