From: John Darrington <john@darrington.wattle.id.au> Date: Sun, 13 Dec 2009 12:19:27 +0000 (+0100) Subject: Set the dictionary encoding of files created by the perl module. X-Git-Tag: fc11-i386-build52^0 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=71fa94505d7d559e3f6bb90092268225db826732;p=pspp-builds.git Set the dictionary encoding of files created by the perl module. This *assumes* that all strings passed from perl will be utf8 encoded. So the documentation has been updated accordingly. --- diff --git a/perl-module/PSPP.xs b/perl-module/PSPP.xs index 77a720ca..fef85510 100644 --- a/perl-module/PSPP.xs +++ b/perl-module/PSPP.xs @@ -584,6 +584,7 @@ CODE: struct file_handle *fh = fh_create_file (NULL, name, fh_default_properties () ); struct sysfile_info *sfi = xmalloc (sizeof (*sfi)); + dict_set_encoding (dict, "UTF-8"); sfi->writer = sfm_open_writer (fh, dict, opts); sfi->dict = dict; sfi->opened = true; diff --git a/perl-module/lib/PSPP.pm b/perl-module/lib/PSPP.pm index e5599908..2dccd10a 100644 --- a/perl-module/lib/PSPP.pm +++ b/perl-module/lib/PSPP.pm @@ -197,7 +197,7 @@ package PSPP::Var; =head3 new ($dict, $name, %input_fmt) Creates and returns a new variable in the dictionary C<dict>. The -new variable will have the name C<name>. +new variable will have the name C<name>. C<name> must be a valid UTF8 string. The input format is set by the C<input_fmt> parameter (See L</PSPP::Fmt>). By default, the write and print formats are the same as the input format. @@ -226,7 +226,7 @@ sub new =head3 set_label ($label) -Sets the variable label to C<label>. +Sets the variable label to C<label>, which must be a valid UTF8 string. =cut @@ -322,6 +322,7 @@ Removes all value labels from the variable. =head3 add_value_label ($key, $label) Adds the value label C<label> to the variable for the value C<key>. +C<label> must be a valid UTF8 string. On error the subroutine returns zero. =head3 add_value_labels (@array) @@ -348,7 +349,7 @@ sub add_value_labels =pod -=head3 set_value_labels ($key, $value) +=head3 set_value_labels ($key, $label) C<Set_value_labels> is identical to calling L</clear_value_labels> followed by L</add_value_labels>. @@ -414,6 +415,7 @@ On error, undef is returned. Appends a case to the system file. C<Case> is an array of scalars, each of which are the values of the variables in the dictionary corresponding to the system file. +If the case contains strings, then the strings must be UTF8 encoded. The special value C<PSPP::SYSMIS> may be used to indicate that a value is system missing. If the array contains less elements than variables in the dictionary, @@ -522,7 +524,7 @@ values retrieved from a reader. Returns a scalar containing a string representing C<value> formatted according to the print format of C<variable>. -In the most common ussage, C<value> should be a value of C<variable>. +In the most common usage, C<value> should be a value of C<variable>. =head3 PSPP::value_is_missing ($value, $variable)