From b7e6dd5f3eeedfb12fe081644bd4d4202c2d8f26 Mon Sep 17 00:00:00 2001 From: Dylan Lloyd Date: Thu, 26 Jan 2012 00:22:15 -0500 Subject: [PATCH] expand unicode trigger for \uXXXX syntax --- lib/DDG/Goodie/Unicode.pm | 2 +- t/Unicode.t | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/DDG/Goodie/Unicode.pm b/lib/DDG/Goodie/Unicode.pm index b3eefcee2..705b243bf 100644 --- a/lib/DDG/Goodie/Unicode.pm +++ b/lib/DDG/Goodie/Unicode.pm @@ -16,7 +16,7 @@ topics 'programming'; use constant { - CODEPOINT_RE => qr/^ \s* U \+ (? [a-f0-9]{4,6}) \s* $/xi, + CODEPOINT_RE => qr/^ \s* (?:U \+|\\(?:u|x)) (? [a-f0-9]{4,6}) \s* $/xi, NAME_RE => qr/^ (? [A-Z][A-Z\s]+) $/xi, CHAR_RE => qr/^ \s* (? .) \s* $/x, UNICODE_RE => qr/^ unicode \s+ (.+) $/xi, diff --git a/t/Unicode.t b/t/Unicode.t index b17eb746a..6398bd8c0 100644 --- a/t/Unicode.t +++ b/t/Unicode.t @@ -15,6 +15,7 @@ ddg_goodie_test( # Raw query, "U+XXXX" 'U+263A' => test_zci("\x{263A} U+263A WHITE SMILING FACE, decimal: 9786, HTML: ☺, UTF-8: 0xE2 0x98 0xBA, block: Miscellaneous Symbols"), + '\u263A' => test_zci("\x{263A} U+263A WHITE SMILING FACE, decimal: 9786, HTML: ☺, UTF-8: 0xE2 0x98 0xBA, block: Miscellaneous Symbols"), # Same should work with the "unicode" start trigger too 'unicode U+263B' => test_zci("\x{263B} U+263B BLACK SMILING FACE, decimal: 9787, HTML: ☻, UTF-8: 0xE2 0x98 0xBB, block: Miscellaneous Symbols"),