shlist

share and manage lists between multiple people
Log | Files | Refs

commit b03aa8ab1236b3d95c4e3d400d9869381da4f4e0
parent 4faf1949be7be39e25de9adfd0e344145cb8ccf2
Author: kyle <kyle@0x30.net>
Date:   Sun, 17 Jan 2016 22:41:30 -0700

sl: enable utf8 support

- turns out that a nice side effect of sending/receiving json is that it's utf8
  ready by default
  - it wasn't being stored properly in the database though
- turns out you need to switch on utf8 support in sqlite
  - doing this lets lists with utf8 names be stored and retrieved correctly

Diffstat:
Mserver/sl | 5++++-
Aserver/tests/utf8/Makefile | 1+
Aserver/tests/utf8/server.log.good | 11+++++++++++
Aserver/tests/utf8/test.pl | 17+++++++++++++++++
4 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/server/sl b/server/sl @@ -682,7 +682,10 @@ sub new { $self->{dbh} = DBI->connect( "dbi:SQLite:dbname=$db_file", "", "", - { RaiseError => 1 } + { + RaiseError => 1, + sqlite_unicode => 1, + } ) or die $DBI::errstr; $self->{dbh}->do("PRAGMA foreign_keys = ON"); diff --git a/server/tests/utf8/Makefile b/server/tests/utf8/Makefile @@ -0,0 +1 @@ +include ../test.mk diff --git a/server/tests/utf8/server.log.good b/server/tests/utf8/server.log.good @@ -0,0 +1,11 @@ +new connection (pid = <digits>) +ssl ok, ver = 'TLSv1_2' cipher = 'ECDHE-RSA-AES128-SHA256' +device_add: success, <digits>:<base64> os <base64> +list_add: device <base64> +list_add: new list name '“ æ 😸' +list_add: new list number is <digits> +lists_get: gathering lists for <base64> +lists_get: found list <digits>:'“ æ 😸' +lists_get: list has 1 members +lists_get: list has 0 items +disconnected! diff --git a/server/tests/utf8/test.pl b/server/tests/utf8/test.pl @@ -0,0 +1,17 @@ +#!/usr/bin/perl -I../ +use strict; +use warnings; +use client; +use test; + +my $A = client->new(); + +# Create a new list with a name composed of 3 parts: +# - a left double quotation mark and +# - ae sorta character thing but where they touch +# - face with medical mask +$A->list_add("\xE2\x80\x9C \xC3\xA6 \xF0\x9F\x98\xB8"); +my ($list) = $A->lists_get(); + +# Check the list name we get back hasn't been mangled in the round trip +fail_msg_ne "\xE2\x80\x9C \xC3\xA6 \xF0\x9F\x98\xB8", $list->{name};