[DiscordArchive] Dose the c++ std:string have a end char like '\0'?
[DiscordArchive] Dose the c++ std:string have a end char like '\0'?
tring have a end char like '\0'?
Archived author: JORGIE • Posted: 2021-03-15T08:02:12.815000+00:00
Original source
Dose the c++ std
tring have a end char like '\0'?
Archived author: MaxtorCoder • Posted: 2021-03-15T08:03:38.158000+00:00
Original source
Yes, it's null terminated
Archived author: JORGIE • Posted: 2021-03-15T08:04:03.443000+00:00
Original source
Yes the c++ append the '\0' . I tested.
Archived author: JORGIE • Posted: 2021-03-15T08:05:48.204000+00:00
Original source
2F 00 00 00 78 9C F3 0A F6 F7 0B 4A 4D CC C9 F5 C9 2C 2E 09 4E 2D 2A 4B 2D F2 0C 70 4C 49 29 4A 2D 2E 4E 2D B6 AA 56 2A 49 2D 2E 51 B2 82 50 B5 0C 00 A1 15 10 EA
30 00 00 00 78 9C F3 0A F6 F7 0B 4A 4D CC C9 F5 C9 2C 2E 09 4E 2D 2A 4B 2D F2 0C 70 4C 49 29 4A 2D 2E 4E 2D B6 AA 56 2A 49 2D 2E 51 B2 82 50 B5 0C 00 A1
Archived author: JORGIE • Posted: 2021-03-15T08:06:01.873000+00:00
Original source
what is 15 10 EA
Archived author: JORGIE • Posted: 2021-03-15T08:07:09.102000+00:00
Original source
```java
public static void main(String[] args) {
String value = "JSONRealmListServerIPAddresses:{\"test\":\"test\"}\0";
byte[] valueBytes = value.getBytes(StandardCharsets.UTF_8);
byte[] outBytes = new byte[valueBytes.length + 4];
ByteBuffer.wrap(outBytes).order(ByteOrder.LITTLE_ENDIAN).putInt(valueBytes.length + 1);
int compressed = CompressDeflate.compress(valueBytes, 0, valueBytes.length, outBytes, 4);
for (int i = 0; i < compressed; i++) {
System.out.printf("%02X ",outBytes[i]);
}
}
```
Archived author: JORGIE • Posted: 2021-03-15T08:10:00.369000+00:00
Original source
```cpp
*reinterpret_cast<uint32*>(compressed.data()) = uint32(json.length() + 1);
```
Archived author: JORGIE • Posted: 2021-03-15T08:11:29.371000+00:00
Original source
Look this code, Why do have to json.length() + 1