digitalmars.D.learn - How to set padding for base64 encoding
- Suliman (7/8) Apr 07 2016 It's look like I should to use template function, but I can't
- rikki cattermole (5/13) Apr 07 2016 "abc" strings are not multiline.
- Suliman (3/21) Apr 07 2016 If I wrap data with """ or ` .... ` I am getting same error. It's
- ag0aep6g (4/6) Apr 07 2016 Wat. We're talking about, aren't we? In D, "abc" strings are multiline,
- rikki cattermole (3/9) Apr 07 2016 Ugh, 2.070.2 definitely has it still.
- ag0aep6g (6/8) Apr 07 2016 I don't think """...""" ever was a thing. You could definitely put
- Kagamin (2/2) Apr 07 2016 Create a range that would remove the newline characters from
- Suliman (3/5) Apr 07 2016 std.file.write("output.png", Base64.decode(myimg.chomp));
- Kagamin (2/2) Apr 07 2016 chomp only trims the string at the beginning and at the end, not
- Andrea Fontana (6/11) Apr 07 2016 Anyway if you need to import a file inside your code probabily
- rikki cattermole (2/4) Apr 07 2016 Can confirm, its \n and \r that is causing the problems here.
- Suliman (5/10) Apr 07 2016 with:
- rikki cattermole (4/13) Apr 07 2016 ok split myimg value into another file, remove all \r and \n separately
- Suliman (2/20) Apr 07 2016 Thanks! That is work!
It's look like my data have padding that cause crush on function: std.file.write("output.png", Base64.decode(myimg));Invalid character:It's look like I should to use template function, but I can't figure out how to use it. Could anybody show example? My code: http://www.everfall.com/paste/id.php?pzpdgvtyb3ji https://dlang.org/phobos/std_base64.html#.Base64
Apr 07 2016
On 07/04/2016 11:49 PM, Suliman wrote:It's look like my data have padding that cause crush on function: std.file.write("output.png", Base64.decode(myimg));"abc" strings are not multiline. Use """abc""" for that purpose. Also perhaps next time test with a smaller file.. say 1 by 1 with no extra chunks.Invalid character:It's look like I should to use template function, but I can't figure out how to use it. Could anybody show example? My code: http://www.everfall.com/paste/id.php?pzpdgvtyb3ji https://dlang.org/phobos/std_base64.html#.Base64
Apr 07 2016
On Thursday, 7 April 2016 at 11:59:09 UTC, rikki cattermole wrote:On 07/04/2016 11:49 PM, Suliman wrote:If I wrap data with """ or ` .... ` I am getting same error. It's seems that problem that last charset is =It's look like my data have padding that cause crush on function: std.file.write("output.png", Base64.decode(myimg));"abc" strings are not multiline. Use """abc""" for that purpose. Also perhaps next time test with a smaller file.. say 1 by 1 with no extra chunks.Invalid character:It's look like I should to use template function, but I can't figure out how to use it. Could anybody show example? My code: http://www.everfall.com/paste/id.php?pzpdgvtyb3ji https://dlang.org/phobos/std_base64.html#.Base64
Apr 07 2016
On 07.04.2016 13:59, rikki cattermole wrote:"abc" strings are not multiline. Use """abc""" for that purpose.Wat. We're talking about, aren't we? In D, "abc" strings are multiline, and """abc""" is not a thing. `"""abc"""` is the same as `"" "abc" ""` is the same as `"" ~ "abc" ~ ""` is the same as `"abc"`.
Apr 07 2016
On 08/04/2016 12:52 AM, ag0aep6g wrote:On 07.04.2016 13:59, rikki cattermole wrote:Ugh, 2.070.2 definitely has it still. I have no idea when that changed...."abc" strings are not multiline. Use """abc""" for that purpose.Wat. We're talking about, aren't we? In D, "abc" strings are multiline, and """abc""" is not a thing. `"""abc"""` is the same as `"" "abc" ""` is the same as `"" ~ "abc" ~ ""` is the same as `"abc"`.
Apr 07 2016
On 07.04.2016 14:57, rikki cattermole wrote:Ugh, 2.070.2 definitely has it still. I have no idea when that changed....I don't think """...""" ever was a thing. You could definitely put newlines in normal "..." literals since basically forever. And concatenation of adjacent "..." literals is also an old feature. I'm fairly certain that """abc""" has always meant ""~"abc"~"". It works, of course, but it's the same as just "abc".
Apr 07 2016
Create a range that would remove the newline characters from string, then decode from that.
Apr 07 2016
On Thursday, 7 April 2016 at 12:19:48 UTC, Kagamin wrote:Create a range that would remove the newline characters from string, then decode from that.std.file.write("output.png", Base64.decode(myimg.chomp)); The same error
Apr 07 2016
chomp only trims the string at the beginning and at the end, not in the middle.
Apr 07 2016
On Thursday, 7 April 2016 at 12:24:06 UTC, Suliman wrote:On Thursday, 7 April 2016 at 12:19:48 UTC, Kagamin wrote:Anyway if you need to import a file inside your code probabily import works better. Something like: auto mystring = import("file.png"); So you don't need any decoding at runtime.Create a range that would remove the newline characters from string, then decode from that.std.file.write("output.png", Base64.decode(myimg.chomp)); The same error
Apr 07 2016
On 08/04/2016 12:19 AM, Kagamin wrote:Create a range that would remove the newline characters from string, then decode from that.Can confirm, its \n and \r that is causing the problems here.
Apr 07 2016
On Thursday, 7 April 2016 at 12:30:59 UTC, rikki cattermole wrote:On 08/04/2016 12:19 AM, Kagamin wrote:with: std.file.write("output.png", Base64.decode(myimg.replace("\r\n", ""))); I am getting same issue. But it should remove all new lines...Create a range that would remove the newline characters from string, then decode from that.Can confirm, its \n and \r that is causing the problems here.
Apr 07 2016
On 08/04/2016 12:39 AM, Suliman wrote:On Thursday, 7 April 2016 at 12:30:59 UTC, rikki cattermole wrote:ok split myimg value into another file, remove all \r and \n separately via e.g. tr. Then read it in, that's what I did.On 08/04/2016 12:19 AM, Kagamin wrote:with: std.file.write("output.png", Base64.decode(myimg.replace("\r\n", ""))); I am getting same issue. But it should remove all new lines...Create a range that would remove the newline characters from string, then decode from that.Can confirm, its \n and \r that is causing the problems here.
Apr 07 2016
On Thursday, 7 April 2016 at 12:43:54 UTC, rikki cattermole wrote:On 08/04/2016 12:39 AM, Suliman wrote:Thanks! That is work!On Thursday, 7 April 2016 at 12:30:59 UTC, rikki cattermole wrote:ok split myimg value into another file, remove all \r and \n separately via e.g. tr. Then read it in, that's what I did.On 08/04/2016 12:19 AM, Kagamin wrote:with: std.file.write("output.png", Base64.decode(myimg.replace("\r\n", ""))); I am getting same issue. But it should remove all new lines...Create a range that would remove the newline characters from string, then decode from that.Can confirm, its \n and \r that is causing the problems here.
Apr 07 2016