我是 C 新手。如何使用 c 访问 zstd 中字符串的压缩值?我知道如何在 python 中做到这一点,例如:
import zstd
import sys
#string to be compressed
q=b'dcvlnzcndsjlffdfjldfds lfdslffnlklmgkds jsjgsnfklsgklsbfjfdflfkjsfbkhxv vnjfnvjfnfdngkjdfngkjdfkgjdfkgbkjfdgkjdgbkjfgkjfgkjfbgkfdknkjvnfkjvfvmflkvm;flmvsfforiofjreiofjeiorfsdhj'
print("compressed string is...")
w=zstd.compress(q)
print(zstd.compress(q))
print('')
print("decompressed string is...")
print(zstd.decompress(w))
print('')
print('decompressed size is =',sys.getsizeof(q),'compressed size is =',sys.getsizeof(w))
输出:
compressed string is...
b"(\xb5/\xfd \xb0\x85\x03\x00b\x89\x17\x14\xa0\xa5\xe9\xdf\x04\xe0\x88\xdc2\x93\x10I\x9d\xe2\xf4\x0f\xab.\x1c&h=\x8cb\x18\x0e\xd7(\x0e\xa3\xb5+\xd4@\xb9S\xcb\xf5\xfc\xd6\xf9u\xf6C\x86\xf5\xc9\xbc\xf4\xbc\xf4\xa7\xd8\xaa\xaf\xea\xba\xe0\x00\x88\x93\x9a_*\xeb\x12\xa3\x8f\xd1[66\x07\xc6O\xa1S\xb5d,\x05\xc6\x92\\\xb6dc\t\x01E'0\x05\x00O\t\xbf\xcbk\xe9\xa0se\x16\xac\x98\x01"
decompressed string is...
b'dcvlnzcndsjlffdfjldfds lfdslffnlklmgkds jsjgsnfklsgklsbfjfdflfkjsfbkhxvvnjfnvjfnfdngkjdfngkjdfkgjdfkgbkjfdgkjdgbkjfgkjfgkjfbgkfdknkjvnfkjvfvmflkvm;flmvsfforiofjreiofjeiorfsdhj'
decompressed size is = 209 compressed size is = 154 '''
如何用 c 语言做同样的事情?在 CI 中尝试了 dictionary_compression 和 simple_compression 但我只能访问大小而不是压缩值。