public function writeChar($fieldValue) { // just use an int, it's more foolproof $this->append(String::valueOf(Character::ord($fieldValue))); }
public function endVisitChar(CharValueCommand $x, Context $ctx) { $this->appendTypedData(CHAR_TYPE, Character::ord($x->getValue())); }
private function deserializeStringTable() { $typeNameCount = $this->readInt(); $buffer = new SSSR_BoundedList(String::clazz(), $typeNameCount); for ($typeNameIndex = 0; $typeNameIndex < $typeNameCount; ++$typeNameIndex) { $str = $this->extract(); // Change quoted characters back. $idx = mb_strpos($str, '\\'); if ($idx !== false) { $buf = ''; $pos = 0; while ($idx >= 0) { $buf .= mb_substr($str, $pos, $idx - $pos); if (++$idx == mb_strlen($str)) { throw new SerializationException("Unmatched backslash: \"{$str}\""); } $ch = mb_substr($str, $idx, 1); $pos = $idx + 1; switch (Character::ord($ch)) { case Character::ord('0'): $buf .= '\\u0000'; break; case Character::ord('!'): $buf .= self::RPC_SEPARATOR_CHAR; break; case Character::ord('\\'): $buf .= $ch; break; case Character::ord('u'): try { $ch = Character::chr(Integer::parseHex(mb_substr($str, $idx + 1, 4))); } catch (NumberFormatException $e) { throw new SerializationException("Invalid Unicode escape sequence \"{$str}\""); } $buf .= $ch; $pos += 4; break; default: throw new SerializationException("Unexpected escape character {$ch} after backslash: \"{$str}\""); } $idx = mb_strpos($str, '\\', $pos); } $buf .= mb_substr($str, $pos); $str = buf; } $buffer->add($str); } if ($buffer->size() != $buffer->getExpectedSize()) { throw new SerializationException('Expected ' . $buffer->getExpectedSize() . ' string table elements; received ' . $buffer->size()); } $this->stringTable = $buffer->toArray(); }
public function endVisitChar(CharValueCommand $x, Context $ctx) { $this->push(String::valueOf(Character::ord($x->getValue()))); }