1-- 2-- Unicode handling 3-- 4-- Note: this test case is known to fail if the database encoding is 5-- EUC_CN, EUC_JP, EUC_KR, or EUC_TW, for lack of any equivalent to 6-- U+00A0 (no-break space) in those encodings. However, testing with 7-- plain ASCII data would be rather useless, so we must live with that. 8-- 9SET client_encoding TO UTF8; 10CREATE TABLE unicode_test ( 11 testvalue text NOT NULL 12); 13CREATE FUNCTION unicode_return() RETURNS text AS $$ 14 return "\xA0" 15$$ LANGUAGE pltcl; 16CREATE FUNCTION unicode_trigger() RETURNS trigger AS $$ 17 set NEW(testvalue) "\xA0" 18 return [array get NEW] 19$$ LANGUAGE pltcl; 20CREATE TRIGGER unicode_test_bi BEFORE INSERT ON unicode_test 21 FOR EACH ROW EXECUTE PROCEDURE unicode_trigger(); 22CREATE FUNCTION unicode_plan1() RETURNS text AS $$ 23 set plan [ spi_prepare {SELECT $1 AS testvalue} [ list "text" ] ] 24 spi_execp $plan [ list "\xA0" ] 25 return $testvalue 26$$ LANGUAGE pltcl; 27SELECT unicode_return(); 28 unicode_return 29---------------- 30 31(1 row) 32 33INSERT INTO unicode_test (testvalue) VALUES ('test'); 34SELECT * FROM unicode_test; 35 testvalue 36----------- 37 38(1 row) 39 40SELECT unicode_plan1(); 41 unicode_plan1 42--------------- 43 44(1 row) 45 46