diff options
author | tetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-05-04 05:13:09 +0000 |
---|---|---|
committer | tetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-05-04 05:13:09 +0000 |
commit | 6bfe5a56288000412826c500aabb76d3a2486331 (patch) | |
tree | 84d2a3ee1049c8b07f83f409185df6605e3d2b5b /LedgerSMB/Form.pm | |
parent | cdc129fc7451af5140c36f2ab084a81b997296ba (diff) |
UTF-8 update backpatch
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/branches/1.2@1123 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'LedgerSMB/Form.pm')
-rwxr-xr-x | LedgerSMB/Form.pm | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/LedgerSMB/Form.pm b/LedgerSMB/Form.pm index a53668b1..011f2666 100755 --- a/LedgerSMB/Form.pm +++ b/LedgerSMB/Form.pm @@ -41,6 +41,9 @@ use Time::Local; use Cwd; use File::Copy; +use charnames ':full'; +use open ':utf8'; + package Form; sub new { @@ -98,7 +101,7 @@ sub new { $self->error( "Access Denied", __line__, __file__ ); } - for ( keys %$self ) { $self->{$_} =~ s/\000//g } + for ( keys %$self ) { $self->{$_} =~ s/\N{NULL}//g } $self; } @@ -138,6 +141,7 @@ sub escape { $str = $self->escape( $str, 1 ) if $1 == 0 && $2 < 44; } + utf8::encode($str); $str =~ s/([^a-zA-Z0-9_.-])/sprintf("%%%02x", ord($1))/ge; $str; @@ -149,7 +153,9 @@ sub unescape { $str =~ tr/+/ /; $str =~ s/\\$//; + utf8::encode($str) if utf8::is_utf8($str); $str =~ s/%([0-9a-fA-Z]{2})/pack("c",hex($1))/eg; + utf8::decode($str); $str =~ s/\r?\n/\n/g; $str; @@ -1582,6 +1588,7 @@ sub dbconnect { my $dbh = DBI->connect( $myconfig->{dbconnect}, $myconfig->{dbuser}, $myconfig->{dbpasswd} ) or $self->dberror; + $dbh->{pg_enable_utf8} = 1; # set db options if ( $myconfig->{dboptions} ) { @@ -1601,6 +1608,7 @@ sub dbconnect_noauto { $myconfig->{dbconnect}, $myconfig->{dbuser}, $myconfig->{dbpasswd}, { AutoCommit => 0 } ) or $self->dberror; + $dbh->{pg_enable_utf8} = 1; # set db options if ( $myconfig->{dboptions} ) { |