# 4.3.5 Extflonums
Converts each v to a string in [display](Writing.html#%28def._%28%28quote._~23~25kernel%29._display%29%29) mode—that is, like ([format](Writing.html#%28def._%28%28quote._~23~25kernel%29._format%29%29) "\~a" v)—then concatenates the results with separator between consecutive items, and then pads or truncates the string to be at least min-width characters and at most max-width characters.
Examples:
> ```racket
> > ( ~a "north" )
> "north"
> > ( ~a ' south )
> "south"
> > ( ~a #"east" )
> "east"
> > ( ~a #\w "e" ' st )
> "west"
> > ( ~a ( list "red" ' green #"blue" ) )
> "(red green blue)"
> > ( ~a 17 )
> "17"
> > ( ~a #e1e20 )
> "100000000000000000000"
> > ( ~a pi )
> "3.141592653589793"
> > ( ~a ( expt 6.1 87 ) )
> "2.1071509386211452e+68"
> ```
The [~a](#%28def._%28%28lib._racket%2Fformat..rkt%29._~7ea%29%29) function is primarily useful for strings, numbers, and other atomic data. The [~v](#%28def._%28%28lib._racket%2Fformat..rkt%29._~7ev%29%29) and [~s](#%28def._%28%28lib._racket%2Fformat..rkt%29._~7es%29%29) functions are better suited to compound data.
Let s be the concatenated string forms of the vs plus separators. If s is longer than max-width characters, it is truncated to exactly max-width characters. If s is shorter than min-width characters, it is padded to exactly min-width characters. Otherwise s is returned unchanged. If min-width is greater than max-width, an exception is raised.


# 4.3.5 Extflonums
If s is longer than max-width characters, it is truncated and the end of the string is replaced with limit-marker. If limit-marker is longer than max-width, an exception is raised. If limit-prefix? is #t, the beginning of the string is truncated instead of the end.
Examples:
> ```racket
> > ( ~a "abcde" #:max-width 5 )
> "abcde"
> > ( ~a "abcde" #:max-width 4 )
> "abcd"
> > ( ~a "abcde" #:max-width 4 #:limit-marker "*" )
> "abc*"
> > ( ~a "abcde" #:max-width 4 #:limit-marker "..." )
> "a..."
> > ( ~a "The quick brown fox" #:max-width 15 #:limit-marker "" )
> "The quick brown"
> > ( ~a "The quick brown fox" #:max-width 15 #:limit-marker "..." )
> "The quick br..."
> > ( ~a "The quick brown fox" #:max-width 15 #:limit-marker "..." #:limit-prefix? #f )
> "The quick br..."
> ```
If s is shorter than min-width, it is padded to at least min-width characters. If align is 'left, then only right padding is added; if align is 'right, then only left padding is added; and if align is 'center, then roughly equal amounts of left padding and right padding are added.
Padding is specified as a non-empty string. Left padding consists of left-pad-string repeated in its entirety as many times as possible followed by a prefix of left-pad-string to fill the remaining space. In contrast, right padding consists of a suffix of right-pad-string followed by a number of copies of right-pad-string in its entirety. Thus left padding starts with the start of left-pad-string and right padding ends with the end of right-pad-string.
Examples:


# 4.3.5 Extflonums
> ```racket
> > ( ~a "apple" #:min-width 20 #:align ' left )
> "apple "
> > ( ~a "pear" #:min-width 20 #:align ' left #:right-pad-string " ." )
> "pear . . . . . . . ."
> > ( ~a "plum" #:min-width 20 #:align ' right #:left-pad-string ". " )
> ". . . . . . . . plum"
> > ( ~a "orange" #:min-width 20 #:align ' center #:left-pad-string "- " #:right-pad-string " -" )
> "- - - -orange- - - -"
> ```
Use width to set both max-width and min-width simultaneously, ensuring that the resulting string is exactly width characters long:
> ```racket
> > ( ~a "terse" #:width 6 )
> "terse "
> > ( ~a "loquacious" #:width 6 )
> "loquac"
> ```
> ```
(~v   v
    ...
   [ #:separator separator
    #:width width
    #:max-width max-width
    #:min-width min-width
    #:limit-marker limit-marker
    #:limit-prefix? limit-prefix?
    #:align align
    #:pad-string pad-string
    #:left-pad-string left-pad-string
    #:right-pad-string right-pad-string)    →    string?
  v : any/c
  separator : string? = " "
  width : (or/c exact-nonnegative-integer? #f) = #f
   max-width   :   (or/c exact-nonnegative-integer? +inf.0)
      =   (or width +inf.0)
  min-width : exact-nonnegative-integer? = (or width 0)
  limit-marker : string? = "..."
  limit-prefix? : boolean? = #f
  align : (or/c 'left 'center 'right) = 'left
  pad-string : non-empty-string? = " "
  left-pad-string : non-empty-string? = pad-string
  right-pad-string : non-empty-string? = pad-string


# 4.3.5 Extflonums
```

Like [~a](#%28def._%28%28lib._racket%2Fformat..rkt%29._~7ea%29%29), but each value is converted like ([format](Writing.html#%28def._%28%28quote._~23~25kernel%29._format%29%29) "\~v" v), the default separator is " ", and the default limit marker is "...".

Examples:

> ```racket
> > ( ~v "north" )
> "\"north\""
> > ( ~v ' south )
> "'south"
> > ( ~v #"east" )
> "#\"east\""
> > ( ~v #\w )
> "#\\w"
> > ( ~v ( list "red" ' green #"blue" ) )
> "'(\"red\" green #\"blue\")"
> ```

Use [~v](#%28def._%28%28lib._racket%2Fformat..rkt%29._~7ev%29%29) to produce text that talks about Racket values.

Example:

> ```racket
> > ( let ( [ nums ( for/list ( [ i 10 ] ) i ) ] ) ( ~a "The even numbers in " ( ~v nums ) " are " ( ~v ( filter even? nums ) ) "." ) )
> "The even numbers in '(0 1 2 3 4 5 6 7 8 9) are '(0 2 4 6 8)."
> ```

> ```
(~s   v
    ...
   [ #:separator separator
    #:width width
    #:max-width max-width
    #:min-width min-width
    #:limit-marker limit-marker
    #:limit-prefix? limit-prefix?
    #:align align
    #:pad-string pad-string
    #:left-pad-string left-pad-string
    #:right-pad-string right-pad-string)    →    string?

  v : any/c
  separator : string? = " "
  width : (or/c exact-nonnegative-integer? #f) = #f
   max-width   :   (or/c exact-nonnegative-integer? +inf.0)
      =   (or width +inf.0)

  min-width : exact-nonnegative-integer? = (or width 0)
  limit-marker : string? = "..."
  limit-prefix? : boolean? = #f
  align : (or/c 'left 'center 'right) = 'left
  pad-string : non-empty-string? = " "
  left-pad-string : non-empty-string? = pad-string
  right-pad-string : non-empty-string? = pad-string
```


# 4.3.5 Extflonums
Like [~a](#%28def._%28%28lib._racket%2Fformat..rkt%29._~7ea%29%29), but each value is converted like ([format](Writing.html#%28def._%28%28quote._~23~25kernel%29._format%29%29) "\~s" v), the default separator is " ", and the default limit marker is "...".
Examples:
> ```racket
> > ( ~s "north" )
> "\"north\""
> > ( ~s ' south )
> "south"
> > ( ~s #"east" )
> "#\"east\""
> > ( ~s #\w )
> "#\\w"
> > ( ~s ( list "red" ' green #"blue" ) )
> "(\"red\" green #\"blue\")"
> ```
> ```
(~e   v
    ...
   [ #:separator separator
    #:width width
    #:max-width max-width
    #:min-width min-width
    #:limit-marker limit-marker
    #:limit-prefix? limit-prefix?
    #:align align
    #:pad-string pad-string
    #:left-pad-string left-pad-string
    #:right-pad-string right-pad-string)    →    string?
  v : any/c
  separator : string? = " "
  width : (or/c exact-nonnegative-integer? #f) = #f
   max-width   :   (or/c exact-nonnegative-integer? +inf.0)
      =   (or width +inf.0)
  min-width : exact-nonnegative-integer? = (or width 0)
  limit-marker : string? = "..."
  limit-prefix? : boolean? = #f
  align : (or/c 'left 'center 'right) = 'left
  pad-string : non-empty-string? = " "
  left-pad-string : non-empty-string? = pad-string
  right-pad-string : non-empty-string? = pad-string


# 4.3.5 Extflonums
```

Like [~a](#%28def._%28%28lib._racket%2Fformat..rkt%29._~7ea%29%29), but each value is converted like ([format](Writing.html#%28def._%28%28quote._~23~25kernel%29._format%29%29) "\~e" v), the default separator is " ", and the default limit marker is "...".

Examples:

> ```racket
> > ( ~e "north" )
> "\"north\""
> > ( ~e ' south )
> "'south"
> > ( ~e #"east" )
> "#\"east\""
> > ( ~e #\w )
> "#\\w"
> > ( ~e ( list "red" ' green #"blue" ) )
> "'(\"red\" green #\"blue\")"
> ```

> ```
(~r   x
   [ #:sign sign
    #:base base
    #:precision precision
    #:notation notation
    #:format-exponent format-exponent
    #:min-width min-width
    #:pad-string pad-string
    #:groups groups
    #:group-sep group-sep
    #:decimal-sep decimal-sep)    →    string?

  x : rational?
   sign   :   ( or/c #f ' + ' ++ ' parens
> ( let ( [ ind ( or/c string? ( list/c string? string? ) ) ] )
> ( list/c ind ind ind ) ) )
      =   #f

   base   :   (or/c (integer-in 2 36) (list/c 'up (integer-in 2 36)))
      =   10

   precision   :   ( or/c exact-nonnegative-integer?
> ( list/c ' = exact-nonnegative-integer? ) )   =   6

   notation   :   ( or/c ' positional ' exponential
> (  →  rational? ( or/c ' positional ' exponential ) ) )
      =   'positional

   format-exponent   :   (or/c #f string? (  →   exact-integer? string?))
      =   #f

  min-width : exact-positive-integer? = 1
  pad-string : non-empty-string? = " "
  groups : (non-empty-listof exact-positive-integer?) = '(3)
  group-sep : string? = ""
  decimal-sep : string? = "."
```


# 4.3.5 Extflonums
Converts the rational number x to a string in either positional or exponential notation, depending on notation. The exactness or inexactness of x does not affect its formatting.
The optional arguments control number formatting:
-  notation — determines whether the number is printed in positional or exponential notation. If notation is a function, it is applied to x to get the notation to be used.
Examples:
> ```racket
> > ( ~r 12345 )
> "12345"
> > ( ~r 12345 #:notation ' exponential )
> "1.2345e+04"
> > ( let ( [ pick-notation ( lambda ( x ) ( if ( or ( < ( abs x ) 0.001 ) (> ( abs x ) 1000 ) ) ' exponential ' positional ) ) ] ) ( for/list ( [ i ( in-range 1 5 ) ] ) ( ~r ( expt 17 i ) #:notation pick-notation ) ) )
> '("17" "289" "4.913e+03" "8.3521e+04")
> ```
-  precision — controls the number of digits after the decimal point (or more accurately, the radix point). When x is formatted in exponential form, precision applies to the significand.
If precision is a natural number, then up to precision digits are displayed, but trailing zeroes are dropped, and if all digits after the decimal point are dropped the decimal point is also dropped. If precision is (list '= digits), then exactly digits digits after the decimal point are used, and the decimal point is never dropped.
Examples:


# 4.3.5 Extflonums
> ```racket
> > ( ~r pi )
> "3.141593"
> > ( ~r pi #:precision 4 )
> "3.1416"
> > ( ~r pi #:precision 0 )
> "3"
> > ( ~r 1.5 #:precision 4 )
> "1.5"
> > ( ~r 1.5 #:precision ' ( = 4 ) )
> "1.5000"
> > ( ~r 50 #:precision 2 )
> "50"
> > ( ~r 50 #:precision ' ( = 2 ) )
> "50.00"
> > ( ~r 50 #:precision ' ( = 0 ) )
> "50."
> ```
-  decimal-sep specifies what decimal separator is printed.
Examples:
> ```racket
> > ( ~r 123.456 )
> "123.456"
> > ( ~r 123.456 #:decimal-sep "," )
> "123,456"
> ```
-  groups controls how digits of the integral part of the number are separated into groups. Rightmost numbers of groups are used to group rightmost digits of the integral part. The leftmost number of groups is used repeatedly to group leftmost digits. The group-sep argument specifies which separator to use between digit groups.
Examples:
> ```racket
> > ( ~r 1234567890 #:groups ' ( 3 ) #:group-sep "," )
> "1,234,567,890"
> > ( ~r 1234567890 #:groups ' ( 3 2 ) #:group-sep "," )
> "12,345,678,90"
> > ( ~r 1234567890 #:groups ' ( 1 3 2 ) #:group-sep "_" )
> "1_2_3_4_5_678_90"
> ```
-  min-width — if x would normally be printed with fewer than min-width digits (including the decimal point but not including the sign indicator), the digits are left-padded using pad-string.
Examples:


# 4.3.5 Extflonums
> ```racket
> > ( ~r 17 )
> "17"
> > ( ~r 17 #:min-width 4 )
> " 17"
> > ( ~r -4 2 #:min-width 4 )
> "- 42"
> > ( ~r 1.5 #:min-width 4 )
> " 1.5"
> > ( ~r 1.5 #:precision 4 #:min-width 10 )
> " 1.5"
> > ( ~r 1.5 #:precision ' ( = 4 ) #:min-width 10 )
> " 1.5000"
> > ( ~r #e1e10 #:min-width 6 )
> "10000000000"
> ```
-  pad-string — specifies the string used to pad the number to at least min-width characters (not including the sign indicator). The padding is placed between the sign and the normal digits of x.
Examples:
> ```racket
> > ( ~r 17 #:min-width 4 #:pad-string "0" )
> "0017"
> > ( ~r -4 2 #:min-width 4 #:pad-string "0" )
> "-0042"
> ```
-
sign — controls how the sign of the number is indicated:
-  If sign is #f (the default), no sign output is generated if x is either positive or zero, and a minus sign is prefixed if x is negative.
Example:
> ```racket
> > ( for/list ( [ x ' ( 17 0 -4 2 ) ] ) ( ~r x ) )
> '("17" "0" "-42")
> ```
-  If sign is '+, no sign output is generated if x is zero, a plus sign is prefixed if x is positive, and a minus sign is prefixed if x is negative.
Example:
> ```racket
> > ( for/list ( [ x ' ( 17 0 -4 2 ) ] ) ( ~r x #:sign ' + ) )
> '("+17" "0" "-42")
> ```
-  If sign is '++, a plus sign is prefixed if x is zero or positive, and a minus sign is prefixed if x is negative.
Example:
> ```racket
> > ( for/list ( [ x ' ( 17 0 -4 2 ) ] ) ( ~r x #:sign ' ++ ) )
> '("+17" "+0" "-42")
> ```
-  If sign is 'parens, no sign output is generated if x is zero or positive, and the number is enclosed in parentheses if x is negative.


# 4.3.5 Extflonums
Example:
> ```racket
> > ( for/list ( [ x ' ( 17 0 -4 2 ) ] ) ( ~r x #:sign ' parens ) )
> '("17" "0" "(42)")
> ```
-  If sign is (list pos-ind zero-ind neg-ind), then pos-ind, zero-ind, and neg-ind are used to indicate positive, zero, and negative numbers, respectively. Each indicator is either a string to be used as a prefix or a list containing two strings: a prefix and a suffix.
Example:
> ```racket
> > ( let ( [ sign-table ' ( ( "" " up" ) "an even " ( "" " down" ) ) ] ) ( for/list ( [ x ' ( 17 0 -4 2 ) ] ) ( ~r x #:sign sign-table ) ) )
> '("17 up" "an even 0" "42 down")
> ```
The default behavior is equivalent to '("" "" "-"); the 'parens mode is equivalent to '("" "" ("(" ")")).
-  base — controls the base that x is formatted in. If base is a number greater than 10, then lower-case letters are used. If base is (list 'up base\*) and base\* is greater than 10, then upper-case letters are used.
Examples:
> ```racket
> > ( ~r 100 #:base 7 )
> "202"
> > ( ~r 4.5 #:base 2 )
> "100.1"
> > ( ~r 3735928559 #:base 16 )
> "deadbeef"
> > ( ~r 3735928559 #:base ' ( up 16 ) )
> "DEADBEEF"
> > ( ~r 3735928559 #:base ' ( up 16 ) #:notation ' exponential )
> "D.EADBEF*16^+07"
> ```
-  format-exponent — determines how the exponent is displayed.
If format-exponent is a string, the exponent is displayed with an explicit sign (as with a sign of '++) and at least two digits, separated from the significand by the “exponent marker” format-exponent:
> ```racket
> > ( ~r 1234 #:notation ' exponential #:format-exponent "E" )
> "1.234E+03"
> ```


# 4.3.5 Extflonums
If format-exponent is #f, the “exponent marker” is "e" if base is 10 and a string involving base otherwise:
> ```racket
> > ( ~r 1234 #:notation ' exponential )
> "1.234e+03"
> > ( ~r 1234 #:notation ' exponential #:base 8 )
> "2.322*8^+03"
> ```
If format-exponent is a procedure, it is applied to the exponent and the resulting string is appended to the significand:
> ```racket
> > ( ~r 1234 #:notation ' exponential #:format-exponent ( lambda ( e ) ( format "E~a" e ) ) )
> "1.234E3"
> ```
Changed in version 8.5.0.5 of package base: Added #:groups, #:group-sep and #:decimal-sep.
> ```
(~.a   v
    ...
   [ #:separator separator
    #:width width
    #:max-width max-width
    #:min-width min-width
    #:limit-marker limit-marker
    #:limit-prefix? limit-prefix?
    #:align align
    #:pad-string pad-string
    #:left-pad-string left-pad-string
    #:right-pad-string right-pad-string)    →    string?
  v : any/c
  separator : string? = ""
  width : (or/c exact-nonnegative-integer? #f) = #f
   max-width   :   (or/c exact-nonnegative-integer? +inf.0)
      =   (or width +inf.0)
  min-width : exact-nonnegative-integer? = (or width 0)
  limit-marker : string? = ""
  limit-prefix? : boolean? = #f
  align : (or/c 'left 'center 'right) = 'left
  pad-string : non-empty-string? = " "
  left-pad-string : non-empty-string? = pad-string
  right-pad-string : non-empty-string? = pad-string


# 4.3.5 Extflonums
(~.v   v
    ...
   [ #:separator separator
    #:width width
    #:max-width max-width
    #:min-width min-width
    #:limit-marker limit-marker
    #:limit-prefix? limit-prefix?
    #:align align
    #:pad-string pad-string
    #:left-pad-string left-pad-string
    #:right-pad-string right-pad-string)    →    string?
  v : any/c
  separator : string? = " "
  width : (or/c exact-nonnegative-integer? #f) = #f
   max-width   :   (or/c exact-nonnegative-integer? +inf.0)
      =   (or width +inf.0)
  min-width : exact-nonnegative-integer? = (or width 0)
  limit-marker : string? = "..."
  limit-prefix? : boolean? = #f
  align : (or/c 'left 'center 'right) = 'left
  pad-string : non-empty-string? = " "
  left-pad-string : non-empty-string? = pad-string
  right-pad-string : non-empty-string? = pad-string
(~.s   v
    ...
   [ #:separator separator
    #:width width
    #:max-width max-width
    #:min-width min-width
    #:limit-marker limit-marker
    #:limit-prefix? limit-prefix?
    #:align align
    #:pad-string pad-string
    #:left-pad-string left-pad-string
    #:right-pad-string right-pad-string)    →    string?
  v : any/c
  separator : string? = " "
  width : (or/c exact-nonnegative-integer? #f) = #f
   max-width   :   (or/c exact-nonnegative-integer? +inf.0)
      =   (or width +inf.0)


# 4.3.5 Extflonums
  min-width : exact-nonnegative-integer? = (or width 0)
  limit-marker : string? = "..."
  limit-prefix? : boolean? = #f
  align : (or/c 'left 'center 'right) = 'left
  pad-string : non-empty-string? = " "
  left-pad-string : non-empty-string? = pad-string
  right-pad-string : non-empty-string? = pad-string```
Like [~a](#%28def._%28%28lib._racket%2Fformat..rkt%29._~7ea%29%29), [~v](#%28def._%28%28lib._racket%2Fformat..rkt%29._~7ev%29%29), and [~s](#%28def._%28%28lib._racket%2Fformat..rkt%29._~7es%29%29), but each v is formatted like ([format](Writing.html#%28def._%28%28quote._~23~25kernel%29._format%29%29) "\~.a" v), ([format](Writing.html#%28def._%28%28quote._~23~25kernel%29._format%29%29) "\~.v" v), and ([format](Writing.html#%28def._%28%28quote._~23~25kernel%29._format%29%29) "\~.s" v), respectively.
------------------------------------------------------------------------


# 4.5 Byte Strings


### 4.5 Byte Strings
> > > <img src="finger.png" width="24" height="24" alt="+" />[Bytes and Byte Strings](https://plt.cs.northwestern.edu/new-snapshots/new-snapshots/doc/local-redirect/index.html?doc=guide&rel=bytestrings.html&version=8.18.0.13) in [The Racket Guide](https://plt.cs.northwestern.edu/new-snapshots/new-snapshots/doc/local-redirect/index.html?doc=guide&rel=index.html&version=8.18.0.13) introduces byte strings.
A byte string is a fixed-length array of bytes. A byte is an exact integer between 0 and 255 inclusive.
A byte string can be mutable or immutable. When an immutable byte string is provided to a procedure like [bytes-set!](#%28def._%28%28quote._~23~25kernel%29._bytes-set%21%29%29), the [exn:fail:contract](exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail~3acontract%29%29) exception is raised. Byte-string constants generated by the default reader (see [Reading Strings](reader.html#%28part._parse-string%29)) are immutable, and they are [interned](reader.html#%28tech._interned%29) in [read-syntax](Reading.html#%28def._%28%28quote._~23~25kernel%29._read-syntax%29%29) mode. Use [immutable?](booleans.html#%28def._%28%28quote._~23~25kernel%29._immutable~3f%29%29) to check whether a byte string is immutable.
Two byte strings are [equal?](Equality.html#%28def._%28%28quote._~23~25kernel%29._equal~3f%29%29) when they have the same length and contain the same sequence of bytes.


# 4.5 Byte Strings
A byte string can be used as a single-valued sequence (see [Sequences](sequences.html)). The bytes of the string serve as elements of the sequence. See also [in-bytes](sequences.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._in-bytes%29%29).
See [Reading Strings](reader.html#%28part._parse-string%29) for information on [read](Reading.html#%28def._%28%28quote._~23~25kernel%29._read%29%29)ing byte strings and [Printing Strings](printing.html#%28part._print-string%29) for information on [print](Writing.html#%28def._%28%28quote._~23~25kernel%29._print%29%29)ing byte strings.
See also: [immutable?](booleans.html#%28def._%28%28quote._~23~25kernel%29._immutable~3f%29%29).


#### 4.5.1 Byte String Constructors, Selectors, and Mutators
> ```
(bytes? v)  →  boolean?
  v : any/c
```
Returns #t if v is a byte string, #f otherwise.

See also immutable-bytes? and mutable-bytes?.

Examples:

> ```racket
> > ( bytes? #"Apple" )
> #t
> > ( bytes? "Apple" )
> #f
> ```

> ```
(make-bytes k [b) → bytes?
  k : exact-nonnegative-integer?
  b : byte? = 0```

Returns a new mutable byte string of length k where each position in the byte string is initialized with the byte b.

Example:

> ```racket
> > ( make-bytes 5 65 )
> #"AAAAA"
> ```

> ```
(bytes b ...) → bytes?
  b : byte?
```
Returns a new mutable byte string whose length is the number of provided bs, and whose positions are initialized with the given bs.
Example:
> ```racket
> > ( bytes 65 112 112 108 101 )
> #"Apple"
> ```
> ```
(bytes  →  immutable-bytes bstr)  →  (and/c bytes? immutable?)
  bstr : bytes?
```

Returns an immutable byte string with the same content as bstr, returning bstr itself if bstr is immutable.

Examples:

> ```racket
> > ( bytes->immutable-bytes ( bytes 65 65 65 ) )
> #"AAA"
> > ( define b ( bytes->immutable-bytes ( make-bytes 5 65 ) ) )
> > ( bytes->immutable-bytes b )
> #"AAAAA"
> > ( eq? ( bytes->immutable-bytes b ) b )
> #t
> ```

> ```
(byte? v)  →  boolean?
  v : any/c
```
Returns #t if v is a byte (i.e., an exact integer between 0 and 255 inclusive), #f otherwise.
Examples:
> ```racket
> > ( byte? 65 )
> #t
> > ( byte? 0 )
> #t
> > ( byte? 256 )
> #f
> > ( byte? -1 )
> #f
> ```
> ```
(bytes-length bstr)  →  exact-nonnegative-integer?
  bstr : bytes?


# 4.5 Byte Strings
```

Returns the length of bstr.

Example:

> ```racket
> > ( bytes-length #"Apple" )
> 5
> ```

> ```
(bytes-ref bstr k)  →  byte?
  bstr : bytes?
  k : exact-nonnegative-integer?
```
(parameter)	→
(-> and/c bytes? (not/c immutable?))```
Changes the byte at position k in bstr to b. The first position in the byte string corresponds to 0, so the position k must be less than the length of the bytes, otherwise the [exn:fail:contract](exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail~3acontract%29%29) exception is raised.
Examples:
> ```racket
> > ( define s ( bytes 65 112 112 108 101 ) )
> > ( bytes-set! s 4 121 )
> > s
> #"Apply"
> ```
> ```
(subbytes bstr start [end) → bytes?
  bstr : bytes?
  start : exact-nonnegative-integer?
  end : exact-nonnegative-integer? = (bytes-length str)
```
Returns a new mutable byte string that is (- end start) bytes long, and that contains the same bytes as bstr from start inclusive to end exclusive. The start and end arguments must be less than or equal to the length of bstr, and end must be greater than or equal to start, otherwise the exn:fail:contract exception is raised.

Examples:

> ```racket
> > ( subbytes #"Apple" 1 3 )
> #"pp"
> > ( subbytes #"Apple" 1 )
> #"pple"
> ```

> ```
(bytes-copy bstr)   →   bytes?
  bstr : bytes?```

Returns ([subbytes](#%28def._%28%28quote._~23~25kernel%29._subbytes%29%29) str 0).

> ```
(parameter)	→
(-> and/c bytes? (not/c immutable?))
```
(inclusive)	→
(-> and/c bytes? (not/c immutable?))```


# 4.5 Byte Strings
Changes dest so that every position in the bytes is filled with b.
Examples:
> ```racket
> > ( define s ( bytes 65 112 112 108 101 ) )
> > ( bytes-fill! s 113 )
> > s
> #"qqqqq"
> ```
> ```
(bytes-append bstr ...) → bytes?
  bstr : bytes?
```

Returns a new mutable byte string that is as long as the sum of the given bstrs’ lengths, and that contains the concatenated bytes of the given bstrs. If no bstrs are provided, the result is a zero-length byte string.

Example:

> ```racket
> > ( bytes-append #"Apple" #"Banana" )
> #"AppleBanana"
> ```

> ```
(bytes  →  list bstr)  →  (listof byte?)
  bstr : bytes?
```
Returns a new list of bytes corresponding to the content of bstr. That is, the length of the list is ([bytes-length](#%28def._%28%28quote._~23~25kernel%29._bytes-length%29%29) bstr), and the sequence of bytes in bstr is the same sequence in the result list.
Example:
> ```racket
> > ( bytes->list #"Apple" )
> '(65 112 112 108 101)
> ```
> ```
(list  →  bytes lst)  →  bytes?
  lst : (listof byte?)


# 4.5 Byte Strings
```
Returns a new mutable byte string whose content is the list of bytes in lst. That is, the length of the byte string is (length lst), and the sequence of bytes in lst is the same sequence in the result byte string.

Example:

> ```racket
> > ( list  →  bytes ( list 65 112 112 108 101 ) )
> #"Apple"
> ```

> ```
(make-shared-bytes k [b) → bytes?
  k : exact-nonnegative-integer?
  b : byte? = 0```

Returns a new mutable byte string of length k where each position in the byte string is initialized with the byte b. For communication among [places](places.html#%28tech._place%29), the new byte string is allocated in the [shared memory space](places.html#%28tech._shared._memory._space%29).

Example:

> ```racket
> > ( make-shared-bytes 5 65 )
> #"AAAAA"
> ```

> ```
(shared-bytes b ...) → bytes?
  b : byte?
```
Returns a new mutable byte string whose length is the number of provided bs, and whose positions are initialized with the given bs. For communication among places, the new byte string is allocated in the shared memory space.
Example:
> ```racket
> > ( shared-bytes 65 112 112 108 101 )
> #"Apple"
> ```


#### 4.5.2 Byte String Comparisons
> ```
(bytes=? bstr1 bstr2 ...) → boolean?
  bstr1 : bytes?
  bstr2 : bytes?```
Returns #t if all of the arguments are [eqv?](Equality.html#%28def._%28%28quote._~23~25kernel%29._eqv~3f%29%29).
Examples:
> ```racket
> > ( bytes=? #"Apple" #"apple" )
> #f
> > ( bytes=? #"a" #"as" #"a" )
> #f
> ```
Changed in version 7.0.0.13 of package base: Allow one argument, in addition to allowing two or more.
>
<colgroup><col style="width: 100%" /></colgroup>

procedure

([bytes<?](#%28def._%28%28quote._~23~25kernel%29._bytes~3c~3f%29%29) bstr1 bstr2 ...) → [boolean?](booleans.html#%28def._%28%28quote._~23~25kernel%29._boolean~3f%29%29)

  bstr1 : [bytes?](#%28def._%28%28quote._~23~25kernel%29._bytes~3f%29%29)

  bstr2 : [bytes?](#%28def._%28%28quote._~23~25kernel%29._bytes~3f%29%29)

Returns #t if the arguments are lexicographically sorted increasing, where individual bytes are ordered by [<](generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._~3c%29%29), #f otherwise.
Examples:
> ```racket
> > ( bytes<? #"Apple" #"apple" )> #t
> > ( bytes<? #"apple" #"Apple" )> #f
> > ( bytes<? #"a" #"b" #"c" )> #t
> ```
Changed in version 7.0.0.13 of package base: Allow one argument, in addition to allowing two or more.
> ```
(bytes>? bstr1 bstr2 ...) → boolean?
  bstr1 : bytes?
  bstr2 : bytes?


# 4.5 Byte Strings
```
Like bytes<?, but checks whether the arguments are decreasing.

Examples:

> ```racket
> > ( bytes>? #"Apple" #"apple" )
> #f
> > ( bytes>? #"apple" #"Apple" )
> #t
> > ( bytes>? #"c" #"b" #"a" )
> #t
> ```

Changed in version 7.0.0.13 of package base: Allow one argument, in addition to allowing two or more.

#### 4.5.3 Bytes to/from Characters, Decoding and Encoding

> ```
(bytes → string/utf-8 bstr [err-char start end) → string?
  bstr : bytes?
  err-char : (or/c #f char?) = #f
  start : exact-nonnegative-integer? = 0
  end : exact-nonnegative-integer? = (bytes-length bstr)```

Produces a string by decoding the start to end substring of bstr as a UTF-8 encoding of Unicode code points. If err-char is not #f, then it is used for bytes that fall in the range 128 to 255 but are not part of a valid encoding sequence. (This rule is consistent with reading characters from a port; see [Encodings and Locales](encodings.html) for more details.) If err-char is #f, and if the start to end substring of bstr is not a valid UTF-8 encoding overall, then the [exn:fail:contract](exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail~3acontract%29%29) exception is raised.

Example:

> ```racket
> > ( bytes->string/utf-8 ( bytes 195 167 195 176 195 182 194 163 ) )
> "çðö£"
> ```

> ```
(bytes → string/locale bstr
   [ err-char
    start
    end)    →    string?

  bstr : bytes?
  err-char : (or/c #f char?) = #f
  start : exact-nonnegative-integer? = 0
  end : exact-nonnegative-integer? = (bytes-length bstr)
```


# 4.5 Byte Strings
Produces a string by decoding the start to end substring of bstr using the current locale’s encoding (see also Encodings and Locales). If err-char is not #f, it is used for each byte in bstr that is not part of a valid encoding; if err-char is #f, and if the start to end substring of bstr is not a valid encoding overall, then the exn:fail:contract exception is raised.
> ```
(bytes → string/latin-1 bstr
   [ err-char
    start
    end)    →    string?
  bstr : bytes?
  err-char : (or/c #f char?) = #f
  start : exact-nonnegative-integer? = 0
  end : exact-nonnegative-integer? = (bytes-length bstr)```
Produces a string by decoding the start to end substring of bstr as a Latin-1 encoding of Unicode code points; i.e., each byte is translated directly to a character using [integer->char](characters.html#%28def._%28%28quote._~23~25kernel%29._integer-~3echar%29%29), so the decoding always succeeds. The err-char argument is ignored, but present for consistency with the other operations.
Example:
> ```racket
> > ( bytes->string/latin-1 ( bytes 254 211 209 165 ) )
> "þÓÑ¥"
> ```
> ```
(string → bytes/utf-8 str [err-byte start end) → bytes?
  str : string?
  err-byte : (or/c #f byte?) = #f
  start : exact-nonnegative-integer? = 0
  end : exact-nonnegative-integer? = (string-length str)


# 4.5 Byte Strings
```
Produces a byte string by encoding the start to end substring of str via UTF-8 (always succeeding). The err-byte argument is ignored, but included for consistency with the other operations.

Examples:

> ```racket
> > ( define b ( bytes  →  string/utf-8 ( bytes 195 167 195 176 195 182 194 163 ) ) )
> > ( string  →  bytes/utf-8 b )
> #"\303\247\303\260\303\266\302\243"
> > ( bytes  →  string/utf-8 ( string  →  bytes/utf-8 b ) )
> "çðö£"
> ```

> ```
(string → bytes/locale str [err-byte start end) → bytes?
  str : string?
  err-byte : (or/c #f byte?) = #f
  start : exact-nonnegative-integer? = 0
  end : exact-nonnegative-integer? = (string-length str)```

Produces a string by encoding the start to end substring of str using the current locale’s encoding (see also [Encodings and Locales](encodings.html)). If err-byte is not #f, it is used for each character in str that cannot be encoded for the current locale; if err-byte is #f, and if the start to end substring of str cannot be encoded, then the [exn:fail:contract](exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail~3acontract%29%29) exception is raised.

> ```
(string → bytes/latin-1 str
   [ err-byte
    start
    end)    →    bytes?

  str : string?
  err-byte : (or/c #f byte?) = #f
  start : exact-nonnegative-integer? = 0
  end : exact-nonnegative-integer? = (string-length str)
```


# 4.5 Byte Strings
Produces a string by encoding the start to end substring of str using Latin-1; i.e., each character is translated directly to a byte using char  →  integer. If err-byte is not #f, it is used for each character in str whose value is greater than 255. If err-byte is #f, and if the start to end substring of str has a character with a value greater than 255, then the exn:fail:contract exception is raised.
Examples:
> ```racket
> > ( define b ( bytes  →  string/latin-1 ( bytes 254 211 209 165 ) ) )
> > ( string  →  bytes/latin-1 b )
> #"\376\323\321\245"
> > ( bytes  →  string/latin-1 ( string  →  bytes/latin-1 b ) )
> "þÓÑ¥"
> ```
> ```
(string-utf-8-length str [start end) → exact-nonnegative-integer?
  str : string?
  start : exact-nonnegative-integer? = 0
  end : exact-nonnegative-integer? = (string-length str)```
Returns the length in bytes of the UTF-8 encoding of str’s substring from start to end, but without actually generating the encoded bytes.
Examples:
> ```racket
> > ( string-utf-8-length ( bytes->string/utf-8 ( bytes 195 167 195 176 195 182 194 163 ) ) )
> 8
> > ( string-utf-8-length "hello" )
> 5
> ```
> ```
(bytes-utf-8-length bstr [err-char start end)
  →  (or/c exact-nonnegative-integer? #f)
  bstr : bytes?
  err-char : (or/c #f char?) = #f
  start : exact-nonnegative-integer? = 0
  end : exact-nonnegative-integer? = (bytes-length bstr)


# 4.5 Byte Strings
```
Returns the length in characters of the UTF-8 decoding of bstr’s substring from start to end, but without actually generating the decoded characters. If err-char is #f and the substring is not a UTF-8 encoding overall, the result is #f. Otherwise, err-char is used to resolve decoding errors as in bytes  →  string/utf-8.

Examples:

> ```racket
> > ( bytes-utf-8-length ( bytes 195 167 195 176 195 182 194 163 ) )
> 4
> > ( bytes-utf-8-length ( make-bytes 5 65 ) )
> 5
> ```

> ```
(bytes-utf-8-ref bstr [skip err-char start end) → (or/c char? #f)
  bstr : bytes?
  skip : exact-nonnegative-integer? = 0
  err-char : (or/c #f char?) = #f
  start : exact-nonnegative-integer? = 0
  end : exact-nonnegative-integer? = (bytes-length bstr)```

Returns the skipth character in the UTF-8 decoding of bstr’s substring from start to end, but without actually generating the other decoded characters. If the substring is not a UTF-8 encoding up to the skipth character (when err-char is #f), or if the substring decoding produces fewer than skip characters, the result is #f. If err-char is not #f, it is used to resolve decoding errors as in [bytes->string/utf-8](#%28def._%28%28quote._~23~25kernel%29._bytes-~3estring%2Futf-8%29%29).

Examples:

> ```racket
> > ( bytes-utf-8-ref ( bytes 195 167 195 176 195 182 194 163 ) 0 )
> #\ç
> > ( bytes-utf-8-ref ( bytes 195 167 195 176 195 182 194 163 ) 1 )
> #\ð
> > ( bytes-utf-8-ref ( bytes 195 167 195 176 195 182 194 163 ) 2 )
> #\ö
> > ( bytes-utf-8-ref ( bytes 65 66 67 68 ) 0 )
> #\A
> > ( bytes-utf-8-ref ( bytes 65 66 67 68 ) 1 )
> #\B
> > ( bytes-utf-8-ref ( bytes 65 66 67 68 ) 2 )
> #\C
> ```

> ```
(bytes-utf-8-index bstr
    skip
   [ err-char
    start
    end)

  →  (or/c exact-nonnegative-integer? #f)
  bstr : bytes?
  skip : exact-nonnegative-integer?
  err-char : (or/c #f char?) = #f
  start : exact-nonnegative-integer? = 0
  end : exact-nonnegative-integer? = (bytes-length bstr)
```


# 4.5 Byte Strings
Returns the offset in bytes into bstr at which the skipth character’s encoding starts in the UTF-8 decoding of bstr’s substring from start to end (but without actually generating the other decoded characters). The result is relative to the start of bstr, not to start. If the substring is not a UTF-8 encoding up to the skipth character (when err-char is #f), or if the substring decoding produces fewer than skip characters, the result is #f. If err-char is not #f, it is used to resolve decoding errors as in bytes  →  string/utf-8.
Examples:
> ```racket
> > ( bytes-utf-8-index ( bytes 195 167 195 176 195 182 194 163 ) 0 )
> 0
> > ( bytes-utf-8-index ( bytes 195 167 195 176 195 182 194 163 ) 1 )
> 2
> > ( bytes-utf-8-index ( bytes 195 167 195 176 195 182 194 163 ) 2 )
> 4
> > ( bytes-utf-8-index ( bytes 65 66 67 68 ) 0 )
> 0
> > ( bytes-utf-8-index ( bytes 65 66 67 68 ) 1 )
> 1
> > ( bytes-utf-8-index ( bytes 65 66 67 68 ) 2 )
> 2
> ```


#### 4.5.4 Bytes to Bytes Encoding Conversion
> ```
(bytes-open-converter from-name to-name)
   →   (or/c bytes-converter? #f)
  from-name : string?
  to-name : string?```
Produces a byte converter to go from the encoding named by from-name to the encoding named by to-name. If the requested conversion pair is not available, #f is returned instead of a converter.
Certain encoding combinations are always available:
-   ([bytes-open-converter](#%28def._%28%28quote._~23~25kernel%29._bytes-open-converter%29%29) "UTF-8" "UTF-8") — the identity conversion, except that encoding errors in the input lead to a decoding failure.
-   ([bytes-open-converter](#%28def._%28%28quote._~23~25kernel%29._bytes-open-converter%29%29) "UTF-8-permissive" "UTF-8") — the identity conversion, except that any input byte that is not part of a valid encoding sequence is effectively replaced by the UTF-8 encoding sequence for #\\uFFFD. (This handling of invalid sequences is consistent with the interpretation of port bytes streams into characters; see [Ports](ports.html).)
-   ([bytes-open-converter](#%28def._%28%28quote._~23~25kernel%29._bytes-open-converter%29%29) "" "UTF-8") — converts from the current locale’s default encoding (see [Encodings and Locales](encodings.html)) to UTF-8.
-   ([bytes-open-converter](#%28def._%28%28quote._~23~25kernel%29._bytes-open-converter%29%29) "UTF-8" "") — converts from UTF-8 to the current locale’s default encoding (see [Encodings and Locales](encodings.html)).


# 4.5 Byte Strings
-   ([bytes-open-converter](#%28def._%28%28quote._~23~25kernel%29._bytes-open-converter%29%29) "platform-UTF-8" "platform-UTF-16") — converts UTF-8 to UTF-16 on Unix and Mac OS, where each UTF-16 code unit is a sequence of two bytes ordered by the current platform’s endianness. On Windows, the conversion is the same as ([bytes-open-converter](#%28def._%28%28quote._~23~25kernel%29._bytes-open-converter%29%29) "WTF-8" "WTF-16") to support unpaired surrogate code units.
-   ([bytes-open-converter](#%28def._%28%28quote._~23~25kernel%29._bytes-open-converter%29%29) "platform-UTF-8-permissive" "platform-UTF-16") — like ([bytes-open-converter](#%28def._%28%28quote._~23~25kernel%29._bytes-open-converter%29%29) "platform-UTF-8" "platform-UTF-16"), but an input byte that is not part of a valid UTF-8 encoding sequence (or valid for the unpaired-surrogate extension on Windows) is effectively replaced with #\\uFFFD.


# 4.5 Byte Strings
-   ([bytes-open-converter](#%28def._%28%28quote._~23~25kernel%29._bytes-open-converter%29%29) "platform-UTF-16" "platform-UTF-8") — converts UTF-16 (bytes ordered by the current platform’s endianness) to UTF-8 on Unix and Mac OS. On Windows, the conversion is the same as ([bytes-open-converter](#%28def._%28%28quote._~23~25kernel%29._bytes-open-converter%29%29) "WTF-16" "WTF-8") to support unpaired surrogates. On Unix and Mac OS, surrogates are assumed to be paired: a pair of bytes with the bits #xD800 starts a surrogate pair, and the #x03FF bits are used from the pair and following pair (independent of the value of the #xDC00 bits). On all platforms, performance may be poor when decoding from an odd offset within an input byte string.
-   ([bytes-open-converter](#%28def._%28%28quote._~23~25kernel%29._bytes-open-converter%29%29) "WTF-8" "WTF-16") — converts the WTF-8 \[[Sapin18](doc-bibliography.html#%28cite._.Sapin18%29)\] superset of UTF-8 to a superset of UTF-16 to support unpaired surrogate code units, where each UTF-16 code unit is a sequence of two bytes ordered by the current platform’s endianness.
-   ([bytes-open-converter](#%28def._%28%28quote._~23~25kernel%29._bytes-open-converter%29%29) "WTF-8-permissive" "WTF-16") — like ([bytes-open-converter](#%28def._%28%28quote._~23~25kernel%29._bytes-open-converter%29%29) "WTF-8" "WTF-16"), but an input byte that is not part of a valid WTF-8 encoding sequence is effectively replaced with #\\uFFFD.


# 4.5 Byte Strings
-   ([bytes-open-converter](#%28def._%28%28quote._~23~25kernel%29._bytes-open-converter%29%29) "WTF-16" "WTF-8") — converts the WTF-16 \[[Sapin18](doc-bibliography.html#%28cite._.Sapin18%29)\] superset of UTF-16 to the WTF-8 superset of UTF-8. The input can include UTF-16 code units that are unpaired surrogates, and the corresponding output includes an encoding of each surrogate in a natural extension of UTF-8.
A newly opened byte converter is registered with the current custodian (see [Custodians](custodians.html)), so that the converter is closed when the custodian is shut down. A converter is not registered with a custodian (and does not need to be closed) if it is one of the guaranteed combinations not involving "" on Unix, or if it is any of the guaranteed combinations (including "") on Windows and Mac OS.
> > > In the Racket software distributions for Windows, a suitable "iconv.dll" is included with "libmzschVERS.dll".
The set of available encodings and combinations varies by platform, depending on the iconv library that is installed; the from-name and to-name arguments are passed on to iconv_open. On Windows, "iconv.dll" or "libiconv.dll" must be in the same directory as "libmzschVERS.dll" (where VERS is a version number), in the user’s path, in the system directory, or in the current executable’s directory at run time, and the DLL must either supply \_errno or link to "msvcrt.dll" for \_errno; otherwise, only the guaranteed combinations are available.


# 4.5 Byte Strings
Use [bytes-convert](#%28def._%28%28quote._~23~25kernel%29._bytes-convert%29%29) with the result to convert byte strings.
Changed in version 7.9.0.17 of package base: Added built-in converters for "WTF-8", "WTF-8-permissive", and "WTF-16".
> ```
(bytes-close-converter converter)  →  void
  converter : bytes-converter?
```
Closes the given converter, so that it can no longer be used with bytes-convert or bytes-convert-end.

> ```
(bytes-convert converter
    src-bstr
   [ src-start-pos
    src-end-pos
    dest-bstr
    dest-start-pos
    dest-end-pos)

   →    (or/c bytes? exact-nonnegative-integer?)
exact-nonnegative-integer?
(or/c 'complete 'continues 'aborts 'error)

  converter : bytes-converter?
  src-bstr : bytes?
  src-start-pos : exact-nonnegative-integer? = 0
   src-end-pos   :   exact-nonnegative-integer?
      =   (bytes-length src-bstr)

  dest-bstr : (or/c bytes? #f) = #f
  dest-start-pos : exact-nonnegative-integer? = 0
   dest-end-pos   :   (or/c exact-nonnegative-integer? #f)
      =   ( and dest-bstr
> ( bytes-length dest-bstr ) )```

Converts the bytes from src-start-pos to src-end-pos in src-bstr.

If dest-bstr is not #f, the converted bytes are written into dest-bstr from dest-start-pos to dest-end-pos. If dest-bstr is #f, then a newly allocated byte string holds the conversion results, and if dest-end-pos is not #f, the size of the result byte string is no more than ([-](generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._-%29%29) dest-end-pos dest-start-pos).

The result of [bytes-convert](#%28def._%28%28quote._~23~25kernel%29._bytes-convert%29%29) is three values:

-   result-bstr or dest-wrote-amt — a byte string if dest-bstr is #f or not provided, or the number of bytes written into dest-bstr otherwise.

-   src-read-amt — the number of bytes successfully converted from src-bstr.

-   'complete, 'continues, 'aborts, or 'error — indicates how conversion terminated:

    -   'complete: The entire input was processed, and src-read-amt will be equal to ([-](generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._-%29%29) src-end-pos src-start-pos).

    -   'continues: Conversion stopped due to the limit on the result size or the space in dest-bstr; in this case, fewer than ([-](generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._-%29%29) dest-end-pos dest-start-pos) bytes may be returned if more space is needed to process the next complete encoding sequence in src-bstr.

    -   'aborts: The input stopped part-way through an encoding sequence, and more input bytes are necessary to continue. For example, if the last byte of input is 195 for a "UTF-8-permissive" decoding, the result is 'aborts, because another byte is needed to determine how to use the 195 byte.

    -   'error: The bytes starting at ([+](generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._%2B%29%29) src-start-pos src-read-amt) bytes in src-bstr do not form a legal encoding sequence. This result is never produced for some encodings, where all byte sequences are valid encodings. For example, since "UTF-8-permissive" handles an invalid UTF-8 sequence by dropping characters or generating “?,” every byte sequence is effectively valid.

Applying a converter accumulates state in the converter (even when the third result of [bytes-convert](#%28def._%28%28quote._~23~25kernel%29._bytes-convert%29%29) is 'complete). This state can affect both further processing of input and further generation of output, but only for conversions that involve “shift sequences” to change modes within a stream. To terminate an input sequence and reset the converter, use [bytes-convert-end](#%28def._%28%28quote._~23~25kernel%29._bytes-convert-end%29%29).

Examples:

> ```racket
> > ( define convert ( bytes-open-converter "UTF-8" "UTF-16" ) )
> > ( bytes-convert convert ( bytes 65 66 67 68 ) )
> #"\376\377\0A\0B\0C\0D" 4 'complete
> > ( bytes 195 167 195 176 195 182 194 163 )
> #"\303\247\303\260\303\266\302\243"
> > ( bytes-convert convert ( bytes 195 167 195 176 195 182 194 163 ) )
> #"\0\347\0\360\0\366\0\243" 8 'complete
> > ( bytes-close-converter convert )
> ```

> ```
(bytes-convert-end converter
   [ dest-bstr
    dest-start-pos
    dest-end-pos)

   →    (or/c bytes? exact-nonnegative-integer?)
(or/c 'complete 'continues)

  converter : bytes-converter?
  dest-bstr : (or/c bytes? #f) = #f
  dest-start-pos : exact-nonnegative-integer? = 0
   dest-end-pos   :   (or/c exact-nonnegative-integer? #f)
      =   ( and dest-bstr
> ( bytes-length dest-bstr ) )
```


# 4.5 Byte Strings
Like bytes-convert, but instead of converting bytes, this procedure generates an ending sequence for the conversion (sometimes called a “shift sequence”), if any. Few encodings use shift sequences, so this function will succeed with no output for most encodings. In any case, successful output of a (possibly empty) shift sequence resets the converter to its initial state.
The result of bytes-convert-end is two values:
-  result-bstr or dest-wrote-amt — a byte string if dest-bstr is #f or not provided, or the number of bytes written into dest-bstr otherwise.
-  'complete or 'continues — indicates whether conversion completed. If 'complete, then an entire ending sequence was produced. If 'continues, then the conversion could not complete due to the limit on the result size or the space in dest-bstr, and the first result is either an empty byte string or 0.
> ```
(bytes-converter? v)   →   boolean?
  v : any/c```
Returns #t if v is a [byte converter](#%28tech._byte._converter%29) produced by [bytes-open-converter](#%28def._%28%28quote._~23~25kernel%29._bytes-open-converter%29%29), #f otherwise.
Examples:
> ```racket
> > ( bytes-converter? ( bytes-open-converter "UTF-8" "UTF-16" ) )
> #t
> > ( bytes-converter? ( bytes-open-converter "whacky" "not likely" ) )
> #f
> > ( define b ( bytes-open-converter "UTF-8" "UTF-16" ) )
> > ( bytes-close-converter b )
> > ( bytes-converter? b )
> #t
> ```
> ```
(locale-string-encoding)  →  any


# 4.5 Byte Strings
```
Returns a string for the current locale’s encoding (i.e., the encoding normally identified by ""). See also system-language+country.

#### 4.5.5 Additional Byte String Functions

|  |  |
|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------:|
|  (require racket/bytes) |  package: base |

The bindings documented in this section are provided by the racket/bytes and racket libraries, but not racket/base.

> ```
(bytes-append* str ... strs) → bytes?
  str : bytes?
  strs : (listof bytes?)```

Like [bytes-append](#%28def._%28%28quote._~23~25kernel%29._bytes-append%29%29), but the last argument is used as a list of arguments for [bytes-append](#%28def._%28%28quote._~23~25kernel%29._bytes-append%29%29), so ([bytes-append*](#%28def._%28%28lib._racket%2Fbytes..rkt%29._bytes-append%2A%29%29) str [...](stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29) strs) is the same as ([apply](procedures.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._apply%29%29) [bytes-append](#%28def._%28%28quote._~23~25kernel%29._bytes-append%29%29) str [...](stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29) strs). In other words, the relationship between [bytes-append](#%28def._%28%28quote._~23~25kernel%29._bytes-append%29%29) and [bytes-append*](#%28def._%28%28lib._racket%2Fbytes..rkt%29._bytes-append%2A%29%29) is similar to the one between [list](pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29) and [list*](pairs.html#%28def._%28%28quote._~23~25kernel%29._list%2A%29%29).

Examples:

> ```racket
> > ( bytes-append* #"a" #"b" ' ( #"c" #"d" ) )
> #"abcd"
> > ( bytes-append* ( cdr ( append* ( map ( lambda ( x ) ( list #", " x ) ) ' ( #"Alpha" #"Beta" #"Gamma" ) ) ) ) )
> #"Alpha, Beta, Gamma"
> ```

> ```
(bytes-join strs sep)  →  bytes?
  strs : (listof bytes?)
  sep : bytes?
```


# 4.5 Byte Strings
Appends the byte strings in strs, inserting sep between each pair of bytes in strs. A new mutable byte string is returned.
Example:
> ```racket
> > ( bytes-join ' ( #"one" #"two" #"three" #"four" ) #" potato " )
> #"one potato two potato three potato four"
> ```
------------------------------------------------------------------------


# 4.6 Characters


### 4.6 Characters
> > > <img src="finger.png" width="24" height="24" alt="+" />Characters in The Racket Guide introduces characters.
Characters range over Unicode scalar values, which includes characters whose values range from #x0 to #x10FFFF, but not including #xD800 to #xDFFF. The scalar values are a subset of the Unicode code points.
Two characters are eqv? if they correspond to the same scalar value. For each scalar value less than 256, character values that are eqv? are also eq?. Characters produced by the default reader are interned in read-syntax mode.
See Reading Characters for information on reading characters and Printing Characters for information on printing characters.
Changed in version 6.1.1.8 of package base: Updated from Unicode 5.0.1 to Unicode 7.0.0.


#### 4.6.1 Characters and Scalar Values
> ```
(char? v) → boolean?
  v : any/c```
Return #t if v is a character, #f otherwise.
> ```
(char  →  integer char)  →  exact-integer?
  char : char?
```

Returns a character’s code-point number.

Example:

> ```racket
> > ( char->integer #\A )
> 65
> ```

> ```
(integer  →  char k)  →  char?
   k   :   ( and/c exact-integer?
> ( or/c ( integer-in 0 #xD7FF )
> ( integer-in #xE000 #x10FFFF ) ) )
```
Return the character whose code-point number is k. For k less than 256, the result is the same object for the same k.
Example:
> ```racket
> > ( integer->char 65 )
> #\A
> ```
> ```
(char-utf-8-length char)  →  (integer-in 1 6)
  char : char?


# 4.6 Characters
```
Produces the same result as (bytes-length (string  →  bytes/utf-8 (string char))).

#### 4.6.2 Character Comparisons

> ```
(char=? char1 char2 ...) → boolean?
  char1 : char?
  char2 : char?```

Returns #t if all of the arguments are [eqv?](Equality.html#%28def._%28%28quote._~23~25kernel%29._eqv~3f%29%29).

Examples:

> ```racket
> > ( char=? #\a #\a )
> #t
> > ( char=? #\a #\A #\a )
> #f
> ```

Changed in version 7.0.0.13 of package base: Allow one argument, in addition to allowing two or more.

> <table data-cellpadding="0" data-cellspacing="0"><colgroup><col style="width: 100%" /></colgroup><tbody><tr><td><blockquote>

<p>procedure</p>

<p>([char<?](#%28def._%28%28quote._~23~25kernel%29._char~3c~3f%29%29) char1 char2 ...) → [boolean?](booleans.html#%28def._%28%28quote._~23~25kernel%29._boolean~3f%29%29)</p></blockquote></td></tr><tr><td>  char1 : [char?](#%28def._%28%28quote._~23~25kernel%29._char~3f%29%29)</td></tr><tr><td>  char2 : [char?](#%28def._%28%28quote._~23~25kernel%29._char~3f%29%29)</td></tr></tbody></table>

Returns #t if the arguments are sorted increasing, where two characters are ordered by their scalar values, #f otherwise.

Examples:

> ```racket
> > ( char<? #\A #\a )> #t
> > ( char<? #\a #\A )> #f
> > ( char<? #\a #\b #\c )> #t
> ```

Changed in version 7.0.0.13 of package base: Allow one argument, in addition to allowing two or more.

> <table data-cellpadding="0" data-cellspacing="0"><colgroup><col style="width: 100%" /></colgroup><tbody><tr><td><blockquote>

<p>procedure</p>

<p>([char<=?](#%28def._%28%28quote._~23~25kernel%29._char~3c~3d~3f%29%29) char1 char2 ...) → [boolean?](booleans.html#%28def._%28%28quote._~23~25kernel%29._boolean~3f%29%29)</p></blockquote></td></tr><tr><td>  char1 : [char?](#%28def._%28%28quote._~23~25kernel%29._char~3f%29%29)</td></tr><tr><td>  char2 : [char?](#%28def._%28%28quote._~23~25kernel%29._char~3f%29%29)</td></tr></tbody></table>

Like [char<?](#%28def._%28%28quote._~23~25kernel%29._char~3c~3f%29%29), but checks whether the arguments are nondecreasing.

Examples:

> ```racket
> > ( char<=? #\A #\a )> #t
> > ( char<=? #\a #\A )> #f
> > ( char<=? #\a #\b #\b )> #t
> ```

Changed in version 7.0.0.13 of package base: Allow one argument, in addition to allowing two or more.

> ```
(char>? char1 char2 ...) → boolean?
  char1 : char?
  char2 : char?
```


# 4.6 Characters
Like char<?, but checks whether the arguments are decreasing.
Examples:
> ```racket
> > ( char>? #\A #\a )
> #f
> > ( char>? #\a #\A )
> #t
> > ( char>? #\c #\b #\a )
> #t
> ```
Changed in version 7.0.0.13 of package base: Allow one argument, in addition to allowing two or more.
> ```
(char>=? char1 char2 ...) → boolean?
  char1 : char?
  char2 : char?```
Like [char<?](#%28def._%28%28quote._~23~25kernel%29._char~3c~3f%29%29), but checks whether the arguments are nonincreasing.
Examples:
> ```racket
> > ( char>=? #\A #\a )
> #f
> > ( char>=? #\a #\A )
> #t
> > ( char>=? #\c #\b #\b )
> #t
> ```
Changed in version 7.0.0.13 of package base: Allow one argument, in addition to allowing two or more.
> ```
(char-ci=? char1 char2 ...) → boolean?
  char1 : char?
  char2 : char?


# 4.6 Characters
```
Returns #t if all of the arguments are eqv? after locale-insensitive case-folding via char-foldcase.

Examples:

> ```racket
> > ( char-ci=? #\A #\a )
> #t
> > ( char-ci=? #\a #\a #\a )
> #t
> ```

Changed in version 7.0.0.13 of package base: Allow one argument, in addition to allowing two or more.

> <table data-cellpadding="0" data-cellspacing="0"><colgroup><col style="width: 100%" /></colgroup><tbody><tr><td><blockquote>

<p>procedure</p>

<p>(char-ci<? char1 char2 ...)  →  boolean?</p></blockquote></td></tr><tr><td>  char1 : char?</td></tr><tr><td>  char2 : char?</td></tr></tbody></table>

Like char<?, but checks whether the arguments would be in increasing order if each was first case-folded using char-foldcase (which is locale-insensitive).

Examples:

> ```racket
> > ( char-ci<? #\A #\a )> #f
> > ( char-ci<? #\a #\b )> #t
> > ( char-ci<? #\a #\b #\c )> #t
> ```

Changed in version 7.0.0.13 of package base: Allow one argument, in addition to allowing two or more.

> <table data-cellpadding="0" data-cellspacing="0"><colgroup><col style="width: 100%" /></colgroup><tbody><tr><td><blockquote>

<p>procedure</p>

<p>(char-ci<=? char1 char2 ...)  →  boolean?</p></blockquote></td></tr><tr><td>  char1 : char?</td></tr><tr><td>  char2 : char?</td></tr></tbody></table>

Like char-ci<?, but checks whether the arguments would be nondecreasing after case-folding.

Examples:

> ```racket
> > ( char-ci<=? #\A #\a )> #t
> > ( char-ci<=? #\a #\A )> #t
> > ( char-ci<=? #\a #\b #\b )> #t
> ```

Changed in version 7.0.0.13 of package base: Allow one argument, in addition to allowing two or more.

> ```
(char-ci>? char1 char2 ...) → boolean?
  char1 : char?
  char2 : char?```

Like [char-ci<?](#%28def._%28%28quote._~23~25kernel%29._char-ci~3c~3f%29%29), but checks whether the arguments would be decreasing after case-folding.

Examples:

> ```racket
> > ( char-ci>? #\A #\a )
> #f
> > ( char-ci>? #\b #\A )
> #t
> > ( char-ci>? #\c #\b #\a )
> #t
> ```

Changed in version 7.0.0.13 of package base: Allow one argument, in addition to allowing two or more.

> ```
(char-ci>=? char1 char2 ...) → boolean?
  char1 : char?
  char2 : char?
```


# 4.6 Characters
Like char-ci<?, but checks whether the arguments would be nonincreasing after case-folding.
Examples:
> ```racket
> > ( char-ci>=? #\A #\a )
> #t
> > ( char-ci>=? #\a #\A )
> #t
> > ( char-ci>=? #\c #\b #\b )
> #t
> ```
Changed in version 7.0.0.13 of package base: Allow one argument, in addition to allowing two or more.


#### 4.6.3 Classifications
> ```
(char-alphabetic? char) → boolean?
  char : char?```
Returns #t if char has the Unicode “Alphabetic” property.
> ```
(char-lower-case? char)  →  boolean?
  char : char?
```

Returns #t if char has the Unicode “Lowercase” property.

> ```
(char-upper-case? char)  →  boolean?
  char : char?
```
Returns #t if char has the Unicode “Uppercase” property.
> ```
(char-title-case? char)  →  boolean?
  char : char?
```

Returns #t if char’s Unicode general category is Lt, #f otherwise.

> ```
(char-numeric? char)  →  boolean?
  char : char?
```
Returns #t if char has a Unicode “Numeric_Type” property value that is not None.
> ```
(char-symbolic? char)  →  boolean?
  char : char?
```

Returns #t if char’s Unicode general category is Sm, Sc, Sk, or So, #f otherwise.

> ```
(char-punctuation? char)  →  boolean?
  char : char?
```
Returns #t if char’s Unicode general category is Pc, Pd, Ps, Pe, Pi, Pf, or Po, #f otherwise.
> ```
(char-graphic? char)  →  boolean?
  char : char?
```
Returns #t if char’s Unicode general category is Ll, Lm, Lo, Lt, Lu, Nd, Nl, No, Mn, Mc, or Me, or if one of the following produces #t when applied to char: char-alphabetic?, char-numeric?, char-symbolic?, or char-punctuation?.

> ```
(char-whitespace? char)   →   boolean?
  char : char?```

Returns #t if char has the Unicode “White_Space” property.

> ```
(char-blank? char)  →  boolean?
  char : char?
```
Returns #t if char’s Unicode general category is Zs or if char is #\\tab. (These correspond to horizontal whitespace.)
> ```


# 4.6 Characters
(char-iso-control? char)  →  boolean?
  char : char?
```

Return #t if char is between #\\nul and #\\u001F inclusive or #\\rubout and #\\u009F inclusive.

> ```
(char-extended-pictographic? char)  →  boolean?
  char : char?
```
(parameter)	→```
Returns a symbol representing the character’s Unicode general category, which is 'lu, 'll, 'lt, 'lm, 'lo, 'mn, 'mc, 'me, 'nd, 'nl, 'no, 'ps, 'pe, 'pi, 'pf, 'pd, 'pc, 'po, 'sc, 'sm, 'sk, 'so, 'zs, 'zp, 'zl, 'cc, 'cf, 'cs, 'co, or 'cn.
> ```
(char-grapheme-break-property char)  →  ?
  char : char?
```

Returns the Unicode graheme-break property for char, which is 'Other, 'CR, 'LF, 'Control, 'Extend, 'ZWJ, 'Regional_Indicator, 'Prepend, 'SpacingMark, 'L, 'V, 'T, 'LV, or 'LVT.

Added in version 8.6.0.1 of package base.

> ```
(make-known-char-range-list)
   →    ( listof ( list/c exact-nonnegative-integer?
> exact-nonnegative-integer?
> boolean? ) )
```


# 4.6 Characters
Produces a list of three-element lists, where each three-element list represents a set of consecutive code points for which the Unicode standard specifies character properties. Each three-element list contains two integers and a boolean; the first integer is a starting code-point value (inclusive), the second integer is an ending code-point value (inclusive), and the boolean is #t when all characters in the code-point range have identical results for all of the character predicates above, have analogous transformations (shifting by the same amount, if any, in code-point space) for [char-downcase](#%28def._%28%28quote._~23~25kernel%29._char-downcase%29%29), [char-upcase](#%28def._%28%28quote._~23~25kernel%29._char-upcase%29%29), and [char-titlecase](#%28def._%28%28quote._~23~25kernel%29._char-titlecase%29%29), and have the same decomposition–normalization behavior. The three-element lists are ordered in the overall result list such that later lists represent larger code-point values, and all three-element lists are separated from every other by at least one code-point value that is not specified by Unicode.


#### 4.6.4 Character Conversions
> ```
(char-upcase char)  →  char?
  char : char?
```
Produces a character consistent with the 1-to-1 code point mapping defined by Unicode. If char has no upcase mapping, char-upcase produces char.

> > > String procedures, such as string-upcase, handle the case where Unicode defines a locale-independent mapping from the code point to a code-point sequence (in addition to the 1-1 mapping on scalar values).

Examples:

> ```racket
> > ( char-upcase #\a )
> #\A
> > ( char-upcase #\λ )
> #\Λ
> > ( char-upcase #\space )
> #\space
> ```

> ```
(char-downcase char)   →   char?
  char : char?```

Like [char-upcase](#%28def._%28%28quote._~23~25kernel%29._char-upcase%29%29), but for the Unicode downcase mapping.

Examples:

> ```racket
> > ( char-downcase #\A )
> #\a
> > ( char-downcase #\Λ )
> #\λ
> > ( char-downcase #\space )
> #\space
> ```

> ```
(char-titlecase char)  →  char?
  char : char?
```
Like char-upcase, but for the Unicode titlecase mapping.
Examples:
> ```racket
> > ( char-upcase #\a )
> #\A
> > ( char-upcase #\λ )
> #\Λ
> > ( char-upcase #\space )
> #\space
> ```
> ```
(char-foldcase char)   →   char?
  char : char?```
Like [char-upcase](#%28def._%28%28quote._~23~25kernel%29._char-upcase%29%29), but for the Unicode case-folding mapping.
Examples:
> ```racket
> > ( char-foldcase #\A )
> #\a
> > ( char-foldcase #\Σ )
> #\σ
> > ( char-foldcase #\ς )
> #\σ
> > ( char-foldcase #\space )
> #\space
> ```


#### 4.6.5 Character Grapheme-Cluster Streaming
> ```
(char-grapheme-step char state)    →    boolean?   fixnum?
  char : char?
  state : fixnum?
```
(single)	→
(-> see Reading Symbols)```

Returns #t if v is a symbol, #f otherwise.

Examples:

> ```racket
> > ( symbol? ' Apple )
> #t
> > ( symbol? 10 )
> #f
> ```

> ```
(parameter)	→
```
(parameter)	→
(-> parameter)```
Returns #t if sym is an [unreadable symbol](#%28tech._unreadable._symbol%29), #f otherwise.
Examples:
> ```racket
> > ( symbol-unreadable? ' Apple )
> #f
> > ( symbol-unreadable? ( gensym ) )
> #f
> > ( symbol-unreadable? ( string->unreadable-symbol "Apple" ) )
> #t
> ```
> ```
(parameter)	→
```
(parameter)	→
(-> symbol → string ' Apple)```

Returns an [interned](reader.html#%28tech._interned%29) symbol whose characters are the same as in str.

Examples:

> ```racket
> > ( string->symbol "Apple" )
> 'Apple
> > ( string->symbol "1" )
> '|1|
> ```

> ```
(parameter)	→
```
(parameter)	→
(-> string → uninterned-symbol "Apple")```
Like ([string->symbol](#%28def._%28%28quote._~23~25kernel%29._string-~3esymbol%29%29) str), but the resulting symbol is a new [unreadable symbol](#%28tech._unreadable._symbol%29). Calling [string->unreadable-symbol](#%28def._%28%28quote._~23~25kernel%29._string-~3eunreadable-symbol%29%29) twice with equivalent strs returns the same symbol, but [read](Reading.html#%28def._%28%28quote._~23~25kernel%29._read%29%29) never produces the symbol.
Examples: