Encoding is not proper when query from Apache/PHP

I have some problem with connection to my Vertica. I use PHP and PDO ODBC driver (thrue unixODBC). When I connect to Vertica via isql and select records from table all data are fine encoded - fields with UTF-8 (non ASCII symbols, for example cyrillic) correctly prints. If connect from web with PHP script and execute same query that fields has some unicode characters like this \u001A\u001A\u001A\u001A Each \u001A represent a one non ASCII symbol and can't be printed. I found that this problem occurs only when you run a script from the web (web server is Apache2). So if you run the script from the console, it's OK. But if you do it from localhost/test.php, we get the issue. It occurs on x32 and x64 versions of Vertica client drivers for Linux and Windows. How does the Apache can influence the outcome results that we get from Vertica?

Comments

  • Hi Mike, we had a similar issue.. Problem was, that apache users locale settings were wrong. When we added locale setting directly to PHP code, then everything seems to be ok with multibyte chars.
      
    Maybe it helps you :)
  • Thank you good man) It's really helped me I tried it before but in my controllers Then I put this string in top of my config file and everything started to work
  • you welcome, I'm glad I was able to help.
  • I know this post is rather old, but I'd like to share our own two days of hell on this problem. In our case, every non-standard characters were outputted as the same binary value (character 27 if memory serves, basically a control code). It took us quite a while to pinpoint Apache as the culprit and even longer to figure out what was going on, because setting the locale in the file didn't change anything.

    As it turns out, there's a file in /etc/Apache2 called envvars. In the middle of it, we found this:

    ## The locale used by some modules like mod_dav
    export LANG=C
    ## Uncomment the following line to use the system default locale instead:
    #. /etc/default/locale

    I remembered reading in the docs that LANG=C tends to garble characters with Vertica, so all we did was swap the comments like this:

    ## The locale used by some modules like mod_dav
    #export LANG=C
    ## Uncomment the following line to use the system default locale instead:
    . /etc/default/locale

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file