perl utf8メモ

UTF8フラッグの場合

utf8::is_utf8($text); # 1となる

ファイルから読み込むと、utf8フラッグのやつが取得できる
open IN, "<:encoding(euc-jp)", "hoge.txt";
open IN, "<:utf8", "hoge.txt";

フラグを落とす
$text = Encode::encode("utf8", $text);
utf8::encode($text);

utf8フラグの文字列を指定した文字コードに変換する
my $new_text = Encode::encode($charset, $wide_char);

utf8フラグなしの文字を その文字の文字コードを指定して、 utf88フラグを付ける
my $wide_char = Encode::decode($non_wide_char_charset, $non_wide_char);
例:my $text = Encode::decode('sjis', $subject);


utf8フラグのない文字列($string)の文字コードの変換
Encode::from_to($string, 'sjis', 'euc-jp');

perl DBIほにゃららら

最近SQL::Abstractがはやっていて、いろいろ調べてみた

user_id in (1, 2, 3)
もとsrc

my @ids = qw/111 222 333/;
my $ids = join(q{,}, @ids);
my $data = $dbh->selectall_hashref(<<"SQL", id);
select id, column1, column2 from table1 where id in ($ids)
SQL


それをいい感じに
my @ids = qw/111 222 333/;
my $sql = SQL::Abstract->new();
my ($stmt, @bind) = $sql->select(
'table1',
[qw/ id column1 column2 /],
+{ id => +{ 'in' => \@ids } },
);
my $data = $dbh->selectall_hashref($stmt, 'id', +{}, @bind);





大なり、小なりとかとか
my $sql = SQL::Abstract->new;
my ($stmt, @bind) = $sql->insert(
'user_data',
'*',
+{ user_id => +{ '>=', 100000} }
);




同じカラムに対するandとか
    ( $stmt, @bind ) = $sql->select(
'table',
[qw/field1 field2/],
+{
reg_date => +{ '<=' => 12345, '>' => 54321 },
}
);

is $stmt, q{SELECT field1, field2 FROM table WHERE ( ( reg_date <= ? AND reg_date > ? ) )},
"stmt";
is_deeply \@bind, [qw/12345 54321/], "bind";




Limitとか



use SQL::Abstract::Limit;
my $sql = SQL::Abstract::Limit->new( limit_dialect => 'LimitOffset' );
( $stmt, @bind ) = $sql->select(
'table', [qw/field1 field2/],
+{ id => '1' },
+{ -desc => 'field3' },
10, 2
);
is $stmt =>
'SELECT field1, field2 FROM table WHERE ( id = ? ) ORDER BY field3 DESC LIMIT 10 OFFSET 2',
'stmt';
is_deeply \@bind, [qw/1/], 'bind';

ReactNativeでAndroid対応する話

前提 ReactNativeでiOS版のアプリをリリースしていて、Android版をリリースする話 トラブルシューティング Build.VERSION_CODES.Q が存在しないエラー compileSdkVersionを29以上にすると解決 メモリー足りないエラー Execu...