php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #5996 Only default charset available in sybase
Submitted: 2000-08-06 19:56 UTC Modified: 2000-08-06 20:12 UTC
From: alf at alpha dot ulatina dot ac dot cr Assigned:
Status: Closed Package: Sybase (dblib) related
PHP Version: 3.0.16 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: alf at alpha dot ulatina dot ac dot cr
New email:
PHP Version: OS:

 

 [2000-08-06 19:56 UTC] alf at alpha dot ulatina dot ac dot cr
Sybase uses the default character set iso_1, which does not correctly handle (among other things) accentuated spanish characters. If such characters are stored on the database, strange characters or question marks may result. I solved it with the following patch:
-+-+-cut from next line. file php3_sybase_charsets.patch-+-+-
--- functions/sybase.c.orig     Mon Feb  7 23:54:51 2000
+++ functions/sybase.c  Sun Aug  6 23:35:07 2000
@@ -260,7 +260,7 @@
 
 static void php3_sybase_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent)
 {
-       char *user,*passwd,*host;
+       char *user,*passwd,*host,*charset;
        char *hashed_details;
        int hashed_details_length;
        sybase_link sybase,*sybase_ptr;
@@ -322,6 +322,25 @@
                                sprintf(hashed_details,"sybase_%s_%s_%s",yyhost->value.str.val,yyuser->value.str.val,yypasswd->value.str.val); /* SAFE */
                        }
                        break;
+               case 4: {
+                               pval *yyhost,*yyuser,*yypasswd,*yycharset;
+
+                               if (getParameters(ht, 4, &yyhost, &yyuser, &yypasswd, &yycharset) == FAILURE) {
+                                       RETURN_FALSE;
+                               }
+                               convert_to_string(yyhost);
+                               convert_to_string(yyuser);
+                               convert_to_string(yypasswd);
+                               convert_to_string(yycharset);
+                               host = yyhost->value.str.val;
+                               user = yyuser->value.str.val;
+                               passwd = yypasswd->value.str.val;
+                               charset = yycharset->value.str.val;
+                               hashed_details_length = yyhost->value.str.len+yyuser->value.str.len+yypasswd->value.str.len+yycharset->value.str.len+6+3;
+                               hashed_details = (char *) emalloc(hashed_details_length+1);
+                               sprintf(hashed_details,"sybase_%s_%s_%s_%s",yyhost->value.str.val,yyuser->value.str.val,yypasswd->value.str.val,yycharset->value.str.val); /* SAFE */
+                       }
+                       break;
                default:
                        WRONG_PARAM_COUNT;
                        break;
@@ -339,6 +358,9 @@
        }
        if (passwd) {
                DBSETLPWD(sybase.login,passwd);
+       }
+       if (charset) {
+               DBSETLCHARSET(sybase.login,charset);
        }
        DBSETLAPP(sybase.login,php3_sybase_module.appname);
        sybase.valid = 1;
-+-+-cut to previous line. file php3_sybase_charsets.patch-+-+-

patch with:
patch -p0 < php3_sybase_charsets.patch
from the php directory (/wherever/php-3.0.16)

This will add a fourth parameter to sybase_connect and sybase_pconnect, where one can set the character set desired for the session. I have not tested it on php4, but the code looks similar, so I guess it should work there too.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-08-06 20:12 UTC] rasmus@php.net
Added to both PHP 3 and PHP 4.  Thanks.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 12:01:27 2024 UTC