Search notes:

System.Text.Encoding - GetBytes()

GetBytes() (a static method of System.Text.Encoding) converts a string to a byte array.
The following script prints different output, depending the encoding of the file and if it is run with PowerShell 5 or PowerShell 7
$enc_utf_8   = [System.Text.Encoding]::GetEncoding('utf-8'     )
$enc_latin_1 = [System.Text.Encoding]::GetEncoding('iso-8859-1')

write-host 'Bytes in UTF-8'
foreach ($b in $enc_utf_8.GetBytes('René')) {
   write-host "  $b"
}
write-host 'Bytes in Latin-1'
foreach ($b in $enc_latin_1.GetBytes('René')) {
   write-host "  $b"
}
For the following conditions: the output is:
Bytes in UTF-8
  82
  101
  110
  195
  169
Bytes in Latin-1
  82
  101
  110
  233
For the following conditions the output is
Bytes in UTF-8
  82
  101
  110
  195
  131
  194
  169
Bytes in Latin-1
  82
  101
  110
  195
  169
For the following conditions
Bytes in UTF-8
  82
  101
  110
  239
  191
  189
Bytes in Latin-1
  82
  101
  110
  63

See also

System.Text.Encoding

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:51 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(51): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(66): id_of(Object(PDO), 'uri', '/notes/Microsof...') #2 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/Microsof...', 1788395812, '216.73.217.21', 'Mozilla/5.0 App...', NULL) #3 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/Microsoft/dot-net/namespaces-classes/System/Text/Encoding/Get/Bytes(103): insert_webrequest() #4 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 51