Encoding question

rflynn at acsalaska.net rflynn at acsalaska.net
Thu Jan 19 17:43:15 UTC 2012


> I'm trying to compile a C++ software on FreeBSD. While compiling, this
> error shows up:
> error: stray '\357' in program
> error: stray '\273' in program
> error: stray '\277' in program
> This file is reported (by file[1]) to be "UTF-8 Unicode (with BOM) C
> program text, with CRLF line terminators" while the rest of the files
> in the package are "ASCII C program text, with CRLF line terminators".
> While I can convert the file with iconv -c -f utf-8 -t ascii file >
> new_file in the post extract stage, I wonder if there is a more
> suitable  way for achieving the same thing. Also I would like to avoid
> this software from depending on iconv.

You have three options:
- have it fixed upstream;
- post process on extract like above;
- post process releases and roll your own tarball which you host yourself.

Fixing upstream is by far the best solution and here's some ammunition:

The Unicode Standard does permit the BOM in UTF-8, but does not require
or recommend its use. Byte order has no meaning in UTF-8 so in UTF-8 the
BOM serves only to identify a text stream or file as UTF-8. [1]

[1] http://en.wikipedia.org/wiki/Byte_order_mark

-- Mel

More information about the freebsd-ports mailing list