utf8 encoding code example
Example 1: python open encoding utf-8
from io import open
f = open("test", mode="r", encoding="utf-8")
Example 2: php set utf8 encoding
<?php
$mysqli = new mysqli("localhost","my_user","my_password","my_db");
if ($mysqli -> connect_errno) {
echo "Failed to connect to MySQL: " . $mysqli -> connect_error;
exit();
}
echo "Initial character set is: " . $mysqli -> character_set_name();
$mysqli -> set_charset("utf8");
echo "Current character set is: " . $mysqli -> character_set_name();
$mysqli -> close();
?>
Example 3: Encoding UTF
String rawString = "Entwickeln Sie mit Vergnügen";
byte[] bytes = rawString.getBytes(StandardCharsets.UTF_8);