Skip to content

Instantly share code, notes, and snippets.

View youkidearitai's full-sized avatar

tekimen youkidearitai

View GitHub Profile
@youkidearitai
youkidearitai / mb_trim.cpp
Created October 2, 2023 13:30
trim function for multibyte support
#include <iostream>
#include <cstring>
#include <string_view>
void mb_trim(size_t *strlen, char **str, const size_t
trim_lengths_num, const size_t *trim_lengths, const char **trim_chars)
{
size_t local_strlen = *strlen;
char *local_str = *str;
for (;;)
--TEST--
GH-11587 Fixed the condition for result set values to be of native type, making it compatible with previous versions. #11616
--EXTENSIONS--
pdo_mysql
--SKIPIF--
<?php
if (!extension_loaded('mysqli') && !extension_loaded('mysqlnd')) {
/* Need connection to detect library version */
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
MySQLPDOTest::skip();
<?php
$pdo = new PDO("mysql:host=127.0.0.1;dbname=ore", "root", "password");
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$pdo->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
$results = $pdo->query("SELECT * FROM test");
foreach ($results as $result) {
var_dump($result);
}
@youkidearitai
youkidearitai / UTF-8-demo.txt
Last active April 18, 2023 21:16
NEON optimizations for UTF-8 from mb_check_encoding berchmarks
UTF-8 encoded sample plain-text file
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
Markus Kuhn [ˈmaʳkʊs kuːn] <http://www.cl.cam.ac.uk/~mgk25/> — 2002-07-25 CC BY
The ASCII compatible UTF-8 encoding used in this plain-text file
is defined in Unicode, ISO 10646-1, and RFC 2279.
--TEST--
mb_check_encoding() marked as valid UTF-8 when valid UTF-8 strings
--EXTENSIONS--
mbstring
zend_test
--SKIPIF--
<?php
if (function_exists('zend_test_is_string_marked_as_valid_utf8') !== true) {
exit("zend_test extension is not included, skip this test");
}
<?php
if (empty($argv[1])) {
$php = "~/php80/bin/php";
} else {
$php = $argv[1];
}
exec($php . " -n -c tmp-php.ini run-tests.php -n -c tmp-php.ini -d extension_dir=./modules ext/mbstring/ -w failed.txt");
$failed = file_get_contents("failed.txt");
--TEST--
Check that strings are marked as not valid UTF-8 (ISO-2022-JP)
--EXTENSIONS--
zend_test
--FILE--
<?php
echo "ISO-2022-JP String:\n";
$a = "a";
$esc1 = "\x1b";
$esc2 = "\x24";
#!/bin/sh
php -v
sapi/cli/php -v
for VAL in `cat diffs.txt`
do
echo ${VAL}
php -r "var_dump(mb_convert_encoding(hex2bin('${VAL}'), 'UTF-8', 'MacJapanese'));"
sapi/cli/php -r "var_dump(mb_convert_encoding(hex2bin('${VAL}'), 'UTF-8', 'MacJapanese'));"
- ー
~ 〜
. 。
, 、
;/ ・
;. …
;, ‥
;h ←
;j ↓
;k ↑
{
"global": {
"check_for_updates_on_startup": true,
"show_in_menu_bar": true,
"show_profile_name_in_menu_bar": true
},
"profiles": [
{
"complex_modifications": {
"parameters": {