Questions tagged [binmode]

13 questions
6
votes
1 answer

Should I pop after each binmode?

When using binmode, should I pop the layers from a possibly previous used binmode? #!/usr/bin/env perl use warnings; use 5.012; use autodie; open my $tty, '>:encoding(utf8)', '/dev/tty'; # ... close $tty; open $tty, '>:encoding(latin1)',…
sid_com
  • 24,137
  • 26
  • 96
  • 187
5
votes
1 answer

Creating image file from base64 data

I have a base64 encoded image data . I am pasting the first few characters string='data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD /2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopG …
Rndomcoder
  • 158
  • 2
  • 18
4
votes
3 answers

"Turn Off" binmode(STDOUT, ":utf8") Locally

I Have The following block in the beginning of my script: #!/usr/bin/perl5 -w use strict; binmode(STDIN, ":utf8"); binmode(STDOUT, ":utf8"); binmode(STDERR, ":utf8"); In some subroutines when there is other encoding(from a distant subroutine), the…
DanielLazarov
  • 160
  • 3
  • 13
4
votes
1 answer

Perl Cannot Binmode STDOUT After Untie Filehandle

I need to disable progressive buffering of an HTTP response. I've got this working in Perl using a file handle class: $|=1; $TIE = tie(*STDOUT,__PACKAGE__); Print statements are stored in an array and are retrieved via the following: $buffer = tied…
xpsd300
  • 175
  • 2
  • 11
3
votes
1 answer

writing a binary file in Julia closest to Perl Binmode

I'm trying to reverse engineer a Julia script from existing Perl code and so far so good, but I've come to a point where I must now write a bunch of binary files in Julia which is something I'm unfamiliar with. I'm wondering if anyone has any…
Chase CB
  • 1,561
  • 1
  • 13
  • 20
2
votes
3 answers

Unable to recombine chunked download of MP3 data

I am using Perl with WWW::Mechanize to download an MP3 file which is served in chunks of 400KB (around 20 seconds). When I save the data with binmode on the file handle, appending each chunk as it arrives, only the first chunk is played correctly;…
communications
  • 145
  • 1
  • 10
2
votes
1 answer

binmode encoding: handling malformed data

With Encode::encode there are different ways to handle malformed data. Does for binmode like binmode STDOUT ":encoding( $encoding_out )" also exist possibilities to handle malformed data?
sid_com
  • 24,137
  • 26
  • 96
  • 187
1
vote
1 answer

Perl: Problem with changing encoding in the middle of reading a file

I am using Perl to load some 'macro' files. These macros can, however, be encoded in various encodings, so there is a directive defined for users writing their macros (i.e. #encoding iso-8859-2 at the beginning of the macro). Every time this…
Peter
  • 13
  • 1
  • 3
1
vote
1 answer

perl special char windows

i try to have german special chars: öäüßÖÄÜ in the output of ma perl console app, but i failed. It's a german win7 system with active codepage 850. #!/usr/bin/perl use warnings; use strict; binmode(STDOUT , ":encoding(cp437)" ) if $^O eq…
Pete
  • 25
  • 2
0
votes
2 answers

Setting binmode on PHP sockets

I am reading binary data from a network socket in PHP. With files, you can use the 'b' mode to specify that the file is binary and should be read as such, but how does one mark a network socket as being binary?
Gavin Brown
  • 113
  • 1
  • 1
  • 5
0
votes
3 answers

How to print out the hexadecimal content of one text using Perl binmode?

Can someone tell me how binmode in Perl can be used to achieve the same function as following one-liner, so as to print out the hex data of one text ? $ perl -nle 'print map {sprintf "%02X",ord} split //' For example, if I input "abcABC", the…
Zii
  • 359
  • 4
  • 10
0
votes
0 answers

Retrieve BLOB field from db2 AS/400 using PHP ODBC library

I need to retrieve some images saved in a blob field of a db400 table. I'm trying with PHP ODBC library, this is the example code: //connect to database if(!$conn = odbc_connect($DNS, $user, $password)){ exit("Error"); } …
fonta7
  • 64
  • 1
  • 4
0
votes
3 answers

Perl read seek tell, and text files. Too many bytes being read. Layers and newline handling

I've a Perl script which analyses a text file (can be UNIX or windows line endings) storing file offsets when it find something of interest. open(my $fh, $filename); my $groups; my %hash; while(<$fh>) { if($_ =~ /interesting/ ) { …
Chris
  • 538
  • 8
  • 19