<p>I have 2 different encoded data, one is 64-bit and the other one is 32-bit, with no compression. Both should result in a float64 array</p>
<p>for the 64-bit I can do this:</p>
<pre><code>dataArray, err = base64.StdEncoding.DecodeString(string(bin))
</code></pre>
<p>and the result is exactly what I should see.</p>
<p>for the 32-bit, I'm trying this:</p>
<pre><code>dataArray, err = base32.StdEncoding.DecodeString(string(bin))
</code></pre>
<p>and I'm getting this error:</p>
<pre><code>32-bit decoder: illegal base32 data at input byte 0
</code></pre>
<p>Can someone explain to me why is this happening ?</p>
<p>go playground: <a href="https://play.golang.org/p/9iSk7s6Nst" rel="nofollow">https://play.golang.org/p/9iSk7s6Nst</a></p>
<p>Just in case, here it is the encoded data:</p>
<p><binary>kHIuSO7RH0X/gHRHiI2nRswfyUT5jN9Eosf0RDC150gjPzpGDVwpRU9JCUhTvIZGZLs9RVO1skaQ5KJHYFA6Rd0w00T68CdFwmaWRr4JFUVi27FHS1ZgRcHo40QXM/lGxx7CROXmJkZ998xE0LufRm7McUXXKX9GQ8YURagVMkYk89lEt7rJRNrm+USDDyJG1kMARm0fl0iDc2JFtOH4RGzsJEZX4ntFfQXqRpx820SGfFBGVhulR//5Ekaz699EJojIRBxRfkfcAENGFWQuRd7nF0X/oSZG5RIFRQtAL0UfLYRJP0UARx1LpkgsunJFIMASSS/YKEh6ftFHCG8VRSbIxEQeuThIe3QbRzRorUaZq7xEz9jWRsaqUEdOXd1HS+xuRQDPEUVOFCdFApGCRQjaQEUb3oBG4HuqRvACckZdxj9FsU3YRE5iCEVytOREsCJNRtRkc0X62zFFlNfbRIO8MkVbagJFlEKXRny/XUUMKJ5GYoR4RQkDrEZk5j1Fg7wORSkX9EWocQxFb8Q1R2LuH0VZn9REN9cVRfnpqUZySgtFTh0BRS5nZEUHR3VFsHzhRNX7EUWmqqtGKuoQRnoHAUbvNxZFg72TSX+m9EfyeMpI6dDoRpnLA0fdJFJIr/ViRV6PLUXQuCRGKblyR6elAEXNR/tFJthkRf0WQUYwYmJG2wANRTjxvUZT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rEYwNrxFr9GURn31K0VPUllFqrNsRRhTeUXKzApHPM7cRWNOu0Y6GXVGdB9URX3ajUfH+iVHzD8KR0I4VEYe4E9FQMRRRc3Ib0WyZANHitXERujfjUazIMNGNnnuRXX3vUamClpGAvAARvxHFkYxi0pF3/xqRbCNfkVcfZxGFzIWRt5eJkagRvJFIzGFRZxugEWXpIJFcY52RZAuUUUyACpFpXRWRTSS6UV00mpFXWQUR8i57EYDbp1GhjyCRvhcXkWdgFNFJrKeRuSvOUake3NGFDLlRSkL6UW35SdGc2J6RW1FXUUSoMZFMeteRSRaYkXVO5VGClYvRngEJEaiFPpFAmBLRfJMrkVg1AxGeTZURep5TUWa0sJFPFSkRQ==</binary></p>
<hr/>**评论:**<br/><br/>JHunz: <pre><p>Your problem is that that input data isn't Base32 encoded. Base32 encoding only uses the characters A-Z (capital only), 2-7, and =. </p></pre>prvst: <pre><p>so does that mean I have to use the Base64 function to decode it?</p></pre>JHunz: <pre><p>It certainly looks like Base64 data to me. Without your conversion code I can't verify that it turns into what you expect it to.</p></pre>prvst: <pre><p>I updated the code on the playground. The implementation is something simple just to get the float values. </p>
<p><a href="https://play.golang.org/p/9iSk7s6Nst" rel="nofollow">https://play.golang.org/p/9iSk7s6Nst</a></p>
<p>As a reference, the first values should be :
[21,248.82 6,523.70 799.10 ...]</p>
<p>Also, the exact same code works for the 64-bit encoding data, but not for this one</p></pre>drvd: <pre><p>Just an educated guess: Maybe you have 32bit floats encoded as base64?</p></pre>prvst: <pre><p>Hum.. yes that makes sense for sure. I swapped all 64's for 32's on the URL posted above and the numbers still don't match...</p></pre>prvst: <pre><p>OK, I fixed the issue.
I changed all 64's to 32's and I changed the counter from == 8 to == 4.</p>
<p>Thank you all for helping</p></pre>dnshane: <pre><p>Surely the problem is the XML that's wrapping the data and the slashes.</p>
<p>So get rid of:</p>
<pre><code><binary>
</binary>
</code></pre>
<p>As well as the / at the beginning of each line, and it should work.</p></pre>prvst: <pre><p>Hey friend,
The <binary> tags are just to mark the start and end of the string, it's a common way of "showing" things making sure people do not add or remove any parts by accident. When converting the string I'm removing the tags for sure, check the URL I posted above.</p>
<p>Thanks for helping though.</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
0 回复
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传