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

  • CentOS 6 and 7 / RHEL Persistent DHCP Solution
  • Debian Ubuntu Mint rc-local service startup error solution rc-local.service: Failed at step EXEC spawning /etc/rc.local: Exec format error
  • MySQL Cheatsheet Guide and Tutorial
  • bash script kill whois or other command that is running for too long
  • Linux tftp listens on all interfaces and IPs by DEFAULT Security Risk Hole Solution
  • python import docx error
  • Cisco Unified Communications Manager Express Cheatsheet CUCME CME
  • Linux Ubuntu Debian Missing privilege separation directory: /var/run/sshd
  • bash how to count the number of columns or words in a line
  • bash if statement how to test program output without assigning to variable
  • RTNETLINK answers: Network is unreachable
  • Centos 7 how to save iptables rules like Centos 6
  • nfs tuning maximum amount of connections
  • qemu-kvm error "Could not initialize SDL(No available video device) - exiting"
  • Centos 7 tftpd will not work with selinux enabled
  • Debian Ubuntu Mint Howto Create Bridge (br0)
  • How To Control Interface that dhcpd server listens to on Debian based Linux like Mint and Ubuntu
  • LUKS unable to type password to unlock during boot on Debian, Ubuntu and Mint
  • Debian Ubuntu and Linux Mint Broken Kernel After Date - New Extra Module Naming Convention
  • Wordpress overwrites and wipes out custom htaccess rules and changes soluton