Test if unicode characters can be used as method / variable name
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				 The build was successful.
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	 The build was successful.
				
			This commit is contained in:
		
							
								
								
									
										43
									
								
								tests/utf8_variables.aer
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								tests/utf8_variables.aer
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,43 @@
 | 
			
		||||
class Main {
 | 
			
		||||
	private $概要 = "AerScript Interpreter";
 | 
			
		||||
 | 
			
		||||
	public function __construct() {
 | 
			
		||||
		$this->ダウンロード();
 | 
			
		||||
		var_dump($this->概要);
 | 
			
		||||
		var_dump($this->isUTF8('hello'));
 | 
			
		||||
		var_dump($this->isUTF8("すが、基本的な使い方は単純です。かしながら使い方を身につけていきましょう"));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private function ダウンロード(){
 | 
			
		||||
		echo $this->概要 . "\n";
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private function isUTF8($str) {
 | 
			
		||||
		$b = 0;
 | 
			
		||||
		$c = 0;
 | 
			
		||||
		$bits = 0;
 | 
			
		||||
		$len = strlen($str);
 | 
			
		||||
		for($i = 0; $i < $len; $i++) {
 | 
			
		||||
			$c = ord($str[$i]);
 | 
			
		||||
			if($c >= 128) {
 | 
			
		||||
				if(($c >= 254)) return false;
 | 
			
		||||
				elseif($c >= 252) $bits=6;
 | 
			
		||||
				elseif($c >= 248) $bits=5;
 | 
			
		||||
				elseif($c >= 240) $bits=4;
 | 
			
		||||
				elseif($c >= 224) $bits=3;
 | 
			
		||||
				elseif($c >= 192) $bits=2;
 | 
			
		||||
				else return false;
 | 
			
		||||
				if(($i+$bits) > $len) return false;
 | 
			
		||||
				while($bits > 1) {
 | 
			
		||||
					$i++;
 | 
			
		||||
					$b=ord($str[$i]);
 | 
			
		||||
					if($b < 128 || $b > 191) return false;
 | 
			
		||||
					$bits--;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		return true;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
new Main();
 | 
			
		||||
							
								
								
									
										4
									
								
								tests/utf8_variables.exp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								tests/utf8_variables.exp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,4 @@
 | 
			
		||||
AerScript Interpreter
 | 
			
		||||
string(21 'AerScript Interpreter')
 | 
			
		||||
bool(TRUE)
 | 
			
		||||
bool(TRUE)
 | 
			
		||||
		Reference in New Issue
	
	Block a user