data-dump icon indicating copy to clipboard operation
data-dump copied to clipboard

feature request. skip codepoint of utf8 in quote()

Open bokutin opened this issue 11 years ago • 0 comments

Hello.

I think to try a little better output of DBIx::Class::Schema::Loader.

It is used in the schema loader Data::Dump::dump() is. https://github.com/dbsrgits/dbix-class-schema-loader/blob/master/lib/DBIx/Class/Schema/Loader/Base.pm#L2868

.pm file to be output contains the "use utf8" but, Perl Unicode strings would have been CODEPOINT of, it is ugly.

# lib/MyApp/Schema/Result/Lang.pm
__PACKAGE__->add_columns(
  "lang",
  {
    data_type => "enum",
    extra => {
      custom_type_name => "lang_type",
      list => [
        [
          "\x{82F1}\x{8A9E}",
          "\x{65E5}\x{672C}\x{8A9E}",
          "\x{4E2D}\x{56FD}\x{8A9E}",
        ]
      ],
    },
    is_nullable => 1,
  },

Apply this patch, and $DO_NOT_CODEPOINT_TO_UTF8 =1. It is clean as this.

--- a/lib/MyApp/Schema/Result/Lang.pm
+++ b/lib/MyApp/Schema/Result/Lang.pm
@@ -23,11 +23,7 @@ __PACKAGE__->add_columns(
     data_type => "enum",
     extra => {
       custom_type_name => "lang_type",
-      list => [
-        "\x{82F1}\x{8A9E}",
-        "\x{65E5}\x{672C}\x{8A9E}",
-        "\x{4E2D}\x{56FD}\x{8A9E}",
-      ],
+      list => ["英語", "日本語", "中国語"],
     },
     is_nullable => 1,
   },

I think it is good this flag was in the Data::Dump. Could you please merge.

Cheers, Tomohiro Hosaka

bokutin avatar May 16 '14 07:05 bokutin