Aer Interpreter Source
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
994 B

  1. class Program {
  2. private string $概要 = "AerScript Interpreter";
  3. public void main() {
  4. $this->ダウンロード();
  5. var_dump($this->概要);
  6. var_dump($this->isUTF8('hello'));
  7. var_dump($this->isUTF8("すが、基本的な使い方は単純です。かしながら使い方を身につけていきましょう"));
  8. }
  9. private void ダウンロード(){
  10. print($this->概要 + "\n");
  11. }
  12. private bool isUTF8(string $str) {
  13. int $b = 0;
  14. int $c = 0;
  15. int $bits = 0;
  16. int $len = strlen($str);
  17. for(int $i = 0; $i < $len; $i++) {
  18. $c = ord($str[$i]);
  19. if($c >= 128) {
  20. if(($c >= 254)) return false;
  21. else if($c >= 252) $bits=6;
  22. else if($c >= 248) $bits=5;
  23. else if($c >= 240) $bits=4;
  24. else if($c >= 224) $bits=3;
  25. else if($c >= 192) $bits=2;
  26. else return false;
  27. if(($i + $bits) > $len) return false;
  28. while($bits > 1) {
  29. $i++;
  30. $b=ord($str[$i]);
  31. if($b < 128 || $b > 191) return false;
  32. $bits--;
  33. }
  34. }
  35. }
  36. return true;
  37. }
  38. }