Tags "byte-order-mark" Result

Does Java have methods to get the various byte order marks?

I am looking for a utility method or constant in Java that will return me the bytes that correspond to the appropriate byte order mark for an encoding, but I can't seem to find one. Is there one? I really would like to do something like: byte[] bom = Charset.forName( CharEncoding.UTF8 ).getByteOrderMark(); Where CharEncoding comes from Apache C

it1352 1 2019-05-22

Using awk to remove the Byte-order mark

has anyone an idea how an awk script (presumably a one-liner) for removing a BOM would look like? Specification: print every line after the first (NR > 1) for the first line: If it starts with #FE #FF or #FF #FE, remove those and print the rest Solution Try this: awk 'NR==1{sub(/^\xef\xbb\xbf/,"")}{print}' INFILE > OUTFILE On the firs

it1352 0 2019-05-08

Insert BOM to a CSV File using PERL

Hi I am having a problem with making my CSV file readable. I am currently trying to do it using PERL. Here's my line of code: #!/usr/bin/perl $infile = @ARGV[0]; $outfile = @ARGV[1]; open(INFILE,"$infile") || die "cannot open input file : $infile : "; open(OUTFILE,">$outfile") || die "cannot open output file"; $/="undef"; while(<INFILE&

it1352 5 2019-05-15

Removing BOM characters using Java

What needs to happen to a string using Java to be an equivalent of vis :set nobomb Assume that BOM comes from the file I am reading. Solution Java does not handle BOM properly. In fact Java handles a BOM like every other char. Found this: http://www.rgagnon.com/javadetails/java-handle-utf8-file-with-bom.html public static final String UTF8_B

it1352 0 2019-05-21

Unwanted new line returned after AJAX request

I'm using an ajax request to send comments to DB. Succesful response is marked by 1. OK The problem actually is that the response from the php script is 1. 2. OK So I debugged the script and noted that the newline character si being added when the script executes the following line: require_once($ABS_APPS."/quotes/classQuote.php"); After

it1352 12 2019-05-07

Removing BOM from gzip'ed CSV in Python

I'm using the following code to unzip and save a CSV file: with gzip.open(filename_gz) as f: file = open(filename, "w"); output = csv.writer(file, delimiter = ',') output.writerows(csv.reader(f, dialect='excel', delimiter = ';')) Everything seems to work, except for the fact that the first characters in the file are unexpected. Googl

it1352 8 2019-05-15

Symfony2 Remove UTF-8 BOM from controller responses

While creating a "force download" action I discovered that ALL responses generated by the controller are including the UTF-8 BOM (). This is not relevant for regular pages, but for downloaded files is undesirable, since JPG or ZIP are reported as corrupt for several Windows viewing softwares. So, the main goal is to remove the BOM from controlle

it1352 0 2020-11-25

PHP Include function outputting unknown char

When using the php include function the include is succesfully executed, but it is also outputting a char before the output of the include is outputted, the char is of hex value 3F and I have no idea where it is coming from, although it seems to happen with every include. At first I thbought it was file encoding, but this doesn't seem to be a pro

it1352 1 2019-05-16

Is it possible to redirect output to a file using the redirection operator without writing a byte-order mark in Powershell?

Is there any way to omit the byte-order mark when redirecting the output stream to a file? For example, if I want to take the contents of an XML file and replace a string with a new value, I need to do create a new encoding and write the new output to a file like the following which is rather ham-handed: $newContent = ( Get-Content .\settings.xml

it1352 0 2020-11-05