Comments (6)
Hey @rybakit!
Good news first!
Using msgpack at 105961a93599a5a12f2e33eaebe7b25ac69f1984
var_dump(bin2hex(msgpack_unpack("\xc4\x01\x80")));
gives me string(2) "80"
Bad news is that we are just packing your data as string/raw this. Even though this is labled raw it was renamed to str in the new spec (but has the same leading bits)? So the a1(101) you are seeing is just a one byte string!
All I did was diagnose stuff though, didn't give you any answers. I think everything is working correctly? Feel free to close if that answer is good, or I would be surprised if I was completely confused :) (I read this through about 5 times...)
from msgpack-php.
Hi @Sean-Der!
According to the spec:
String extending Raw type represents a UTF-8 string
Binary extending Raw type represents a byte array
So I would expect "\x80"
to be packed as a byte array (bin 8), not a string. I've also tested it with a python library which returns c40180
, not a180
.
from msgpack-php.
Right now we don't look at the string we are packing, so "\x80" is just handled like every other string. I will look at the Python library and see how they implemented packing (There isn't a dedicated binary type, so maybe they walk the string and decide based on its contents?)
Is this behavior breaking PHP <-> Python for you right now?
from msgpack-php.
There isn't a dedicated binary type, so maybe they walk the string and decide based on its contents?
They check if the string is Unicode before packing it:
...
elif isinstance(obj, unicode):
_pack_string(obj, fp)
elif isinstance(obj, str):
_pack_binary(obj, fp)
...
Is this behavior breaking PHP <-> Python for you right now?
I'm not affected by this right now, but I saw these tickets (#36, #53) were closed and assumed that the bin family is fully supported. I also wrote a pure php implementation of the msgpack protocol and tried to run my tests against this pecl extension and found that they fail on bin
and ext
formats.
from msgpack-php.
I really appreciate you making msgpack-php better just because! Sure needs some people who care about quality.. as I mess things up!
Let me look at what I can do with this! The only part that is rough with this is that check will increase runtime. All I have is a char * + int, so I will have to see what the right way to handle that.
thanks (also I owe you a merge and a bugfix already I should have time this week)
from msgpack-php.
@Sean-Der Maybe this can be used to detect utf8 strings? Also, you may consider adding a flag to enable/disable utf8/bin auto-detection. That will help to keep encoding fast for the cases when the string type is known beforehand.
from msgpack-php.
Related Issues (20)
- Recursion encoded as NULL
- 034.phpt fails HOT 1
- Consider making MessagePackUnpacker cloneable
- Memory Consumption Problem in 2.1.0 HOT 1
- msgpack (un)pack error HOT 11
- try to compile from source by zts-phpize HOT 2
- php_add_session_var: symbol not found HOT 1
- More and more memory, there seems to be a leak HOT 1
- PHP 8 recursion
- my code is printed ,but out to show the garbled code, why? HOT 2
- How to get in touch about a security issue? HOT 2
- Support PHP 8.1's ZEND_ACC_NOT_SERIALIZABLE flag on zend_class_entries
- uint32 numbers are incorrectly serialized on Windows HOT 1
- PHP 8.2 - msgpack_check_ht_is_map assertion error in ZEND_HASH_FOREACH_BUCKET
- PHP 8.2: msgpack_unpack: Support deprecation of dynamic properties, forbid dynamic properties in `readonly` classes HOT 1
- MsgPack TS non TS fail HOT 5
- Compilation error reported HOT 3
- Question: release 2.2.0
- Serializing/Unserializing Enum
- Windows DLL available to download
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from msgpack-php.