Michael Schlenker wrote:
So your above code probably should work, as co80 was a valid NULL inThere was some discussion of this topic before Xmas between some UNICODE people and some of the Core Team. We couldn't reach agreement over what
some UTF-8, but nowadays this is broken.
the right way forward was; their preferred solutions (which varied from making the app exit immediately to substituting such sequences with the UNICODE "unknown character sequence" character) would have broken far
too much existing code and data for our taste, and our preferred
solutions (which can be summed up largely by the IETF dictum "Be liberal
in what you accept and strict in what you generate") had them throwing
up their arms in horror. We did not see eye-to-eye... :^(
Donal.
Wow, this is an old discussion ... but this is the problem I seem to have with Tcl 8.6.12 ...
I need to build a BLOB for a field in an SQLite table. It should start with these four bytes:
byte[2] magic = 0x4750;
byte version;
byte flags;
So, the first one is ASCII "GP", the second one should be a zero as an "8-bit unsigned integer" and the third one is a byte with flags that is "00000011" (only the two right-most bits are set) in my case. What I do is
binary format a2BB8 GP 0 00000011
Looking at the hex representation of the BLOB, it looks like this: "47 50 c0 80 03"
I can see the correct first two bytes (the "GP") and the last byte (the flags) but the NULL comes out as "c080".
Wow, this is an old discussion ... but this is the problem I seem to have with Tcl 8.6.12 ...
I need to build a BLOB for a field in an SQLite table. It should start with these four bytes:
byte[2] magic = 0x4750;
byte version;
byte flags;
So, the first one is ASCII "GP", the second one should be a zero as
an "8-bit unsigned integer" and the third one is a byte with flags
that is "00000011" (only the two right-most bits are set) in my case.
What I do is
binary format a2BB8 GP 0 00000011
Looking at the hex representation of the BLOB, it looks like this:
"47 50 c0 80 03"
I can see the correct first two bytes (the "GP") and the last byte
(the flags) but the NULL comes out as "c080".
Even if I do
set BLOB \x47\x50\x00\x03
I get the same output.
So, how do I get the BLOB to look like this (hex representation): "47 50 00 03"
Torsten Berg <be...@typoscriptics.de> wrote:
Wow, this is an old discussion ... but this is the problem I seem to have with Tcl 8.6.12 ...
I need to build a BLOB for a field in an SQLite table. It should start with these four bytes:
byte[2] magic = 0x4750;
byte version;
byte flags;
So, the first one is ASCII "GP", the second one should be a zero as
an "8-bit unsigned integer" and the third one is a byte with flags
that is "00000011" (only the two right-most bits are set) in my case.
What I do is
binary format a2BB8 GP 0 00000011
Looking at the hex representation of the BLOB, it looks like this:
"47 50 c0 80 03"
I can see the correct first two bytes (the "GP") and the last byte
(the flags) but the NULL comes out as "c080".
Even if I do
set BLOB \x47\x50\x00\x03
I get the same output.
So, how do I get the BLOB to look like this (hex representation): "47 50 00 03"You have not stated how you are looking at the "hex representation".
If you ask for the 'hex' in the normal Tcl way, it appears to work
properly:
$ rlwrap tclsh
% set blob [binary format a2BB8 GP 0 00000011]
GP
% binary scan $blob H* hex
1
% set hex
47500003
%
And as Christian pointed out, the hex you quote is the UTF-8 encoding
of the binary blob. So it looks like you are gaining a UTF-8 encoding
of the blob somewhere.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 496 |
Nodes: | 16 (2 / 14) |
Uptime: | 58:49:21 |
Calls: | 9,760 |
Calls today: | 1 |
Files: | 13,742 |
Messages: | 6,185,442 |