charat in PHP convert non-English characters into code

This is basically URL decoding to the decimal code but nothing in PHPworks how you'd expect it.

Here are online tools to verify and check your work, it's important when querying databases with non-English characters:

http://yehg.net/encoding/index.php#

http://meyerweb.com/eric/tools/dencoder/

http://www.codetable.net/decimal/65398

Japanese:

http://symbolcodes.tlt.psu.edu/bylanguage/japanesechartkatakana.html

Charat code for PHP:

http://eqcode.com/wiki/CharCodeAt

function charCodeAt($str, $num) { return utf8_ord(utf8_charAt($str, $num)); }
function utf8_ord($ch) {
  $len = strlen($ch);
  if($len <= 0) return false;
  $h = ord($ch{0});
  if ($h <= 0x7F) return $h;
  if ($h < 0xC2) return false;
  if ($h <= 0xDF && $len>1) return ($h & 0x1F) <<  6 | (ord($ch{1}) & 0x3F);
  if ($h <= 0xEF && $len>2) return ($h & 0x0F) << 12 | (ord($ch{1}) & 0x3F) << 6 | (ord($ch{2}) & 0x3F);          
  if ($h <= 0xF4 && $len>3) return ($h & 0x0F) << 18 | (ord($ch{1}) & 0x3F) << 12 | (ord($ch{2}) & 0x3F) << 6 | (ord($ch{3}) & 0x3F);
  return false;
}
function utf8_charAt($str, $num) { return mb_substr($str, $num, 1, 'UTF-8'); }

$str = "A가★あ中";
$code = charCodeAt($str, 2);
echo $code; // 9733

Tags:

charat, php, convert, characters, codethis, url, decoding, decimal, online, verify, querying, databases, http, yehg, encoding, index, meyerweb, dencoder, www, codetable, symbolcodes, tlt, psu, edu, bylanguage, japanesechartkatakana, html, eqcode, wiki, charcodeat, str, num, utf, _ord, _charat, ch, len, strlen, ord, xc, xdf, xef, xf, mb_substr, quot, echo,

Latest Articles

  • Debian and Netplan
  • CentOS 8 how to restart the network!
  • CentOS 8 how to convert to a bootable mdadm RAID software array
  • ADATA USB Thumb Drive Issues
  • KMODE EXCEPTION NOT HANDLED - QEMU/KVM Won't Boot Windows 2016 or 10 Image or Physical Machine
  • Linux Mint / Ubuntu / Debian Mate Disable Guest Session and Hide Usernames on Lightdm Login screen GUI
  • SSH How To Create Public/Private Key Pair and with a Larger Keysize than 2048 bits
  • selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service geckodriver
  • python ModuleNotFoundError: No module named 'bs4' even though you have the module
  • ssh how to connect using a SOCKS 5 proxy with nc and proxycommand
  • Enable AMDGPU Linux Driver
  • apache symlinks denied even with followsymlinks
  • chown how to change ownership on a symlink
  • how to use ifplugd in Linux to execute a command or script when a NIC cable is unplugged or plugged in
  • dd how to backup and restore disk images including compression with gzip
  • mpv / mplayer with Radeon / AMD GPU Video Card Driver enable VDPAU GPU Accelerated Video Decoding
  • Wordpress Reset Blog User Password from MySQL Using Linux Bash and not PHPMyadmin
  • Ubuntu Linux Mint Debian xorg performance and tear-free tuning for AMD Radeon Based Cards
  • Centos 7 Stopped and Disabled Firewalld and ports still blocked
  • MariaDB / MySQL Reset Root Forgotten Password on Centos 7