Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Unpack string #2

Closed
cmario opened this Issue · 1 comment

2 participants

@cmario

Hi,

I've a problem with some char like 'è' or 'ù' when I read data from cassandra. The code that unpacks the string is the follow:


public static function unpackString($value, $length)  {
        $unpacked = unpack('c'.$length.'chars', $value);
        $out = '';
        
        foreach($unpacked as $element) {
            if($element > 0) {
                $out .= chr($element);
            }
        }
        
        return $out;
}

If I replace 'c' with 'C' (unsigned char), this solve the problem.

I'd to like to know which is the sense to split a string into characters and then join characters into a string.

Thanks in advance
Mario

@kallaspriit kallaspriit was assigned
@kallaspriit
Owner

Made a test for it and you are correct, such characters were not handled properly. Using unsigned char solved the problem :)

@kallaspriit kallaspriit referenced this issue from a commit
@kallaspriit Fixed issued #1 and #2
- integer columns handled correctly
- special character strings unpacked correctly
91fc18f
@gwagner gwagner referenced this issue from a commit in gwagner/Cassandra-PHP-Client-Library
@kallaspriit Fixed issued #1 and #2
- integer columns handled correctly
- special character strings unpacked correctly
6b700a8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.