Robbrad Posted June 8, 2012 Share Posted June 8, 2012 Can anyone help me convert this VB function to PHP - I know php but no idea where to start Public Function Decompress(ByVal compressedString As String) As String 'Dim gzBuffer As Byte() = Convert.FromBase64String(compressedString) Dim gzBuffer As Byte() = HexToByte(compressedString) Using stream As New GZipStream(New MemoryStream(gzBuffer), CompressionMode.Decompress) Const size As Integer = 4096 Dim buffer As Byte() = New Byte(size - 1) {} Using memory As New MemoryStream() Dim count As Integer = 0 Do count = stream.Read(buffer, 0, size) If count > 0 Then memory.Write(buffer, 0, count) End If Loop While count > 0 Return Encoding.UTF8.GetString(memory.ToArray()) End Using End Using End Function Link to comment https://forums.phpfreaks.com/topic/263876-need-some-help-converting-this-vb-function-to-php/ Share on other sites More sharing options...
Jessica Posted June 8, 2012 Share Posted June 8, 2012 I'd start with the first line, then go from there. Link to comment https://forums.phpfreaks.com/topic/263876-need-some-help-converting-this-vb-function-to-php/#findComment-1352254 Share on other sites More sharing options...
boompa Posted June 8, 2012 Share Posted June 8, 2012 Maybe gzuncompress would work? Link to comment https://forums.phpfreaks.com/topic/263876-need-some-help-converting-this-vb-function-to-php/#findComment-1352314 Share on other sites More sharing options...
Robbrad Posted June 9, 2012 Author Share Posted June 9, 2012 Ok here I go <?php $string='0x1F8B0800000000000000654E316EC3300CEC5CA07FE0D6AD909D1628E0A1C8D01F74E422CB94CD46A11C4A6E5018F97B6967EC72381EC9BB5B516B6CD04BE11DC23C36ED5B8B03C5E8364C5EC6C61D0E2BC62CB5F6C988C358AE5C0AC6592F2DC630792D541D1C957DEA6E76D260144EFF57B7A7C715434E59CD0A3A541A1C8E4A240EFBB490EBEC027F98AE2796E11597D0E0EC75C013D1BC8360F1EF0EC316B115695BF89A08CE390B70816ABC571EA74AA542EEBF295460D975642B069F5EEBF45C6CB27707E5F4FBB14558EC1D83D9EEEC28D9BE142E8B59719697BB6C051FFE00D09796A337010000'; Function decompressRtf($string) gzBuffer = hexdec($string); size = (int)4096; //Stuck on this next part buffer As Byte() = New Byte(size - 1) {} Using memory As New MemoryStream() Dim count As Integer = 0 Do count = stream.Read(buffer, 0, size) If count > 0 Then memory.Write(buffer, 0, count) End If Loop While count > 0 Return Encoding.UTF8.GetString(memory.ToArray()) End Using End Using End Function $output = decompressRtf($string); ?> Link to comment https://forums.phpfreaks.com/topic/263876-need-some-help-converting-this-vb-function-to-php/#findComment-1352475 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.