l...@gnu.org (Ludovic Courtès) writes: > [...] > >> + (lambda (file) >> + (catch 'encoding-error >> + (lambda () >> + (substitute* file >> + (("VERSIONED_JNI_LIB_NAME\\(\"(.*)\", >> \"(.*)\"\\)" >> + _ name version) >> + (format #f "\"~a\"" (find-library name))) >> + (("JNI_LIB_NAME\\(\"(.*)\"\\)" _ name) >> + (format #f "\"~a\"" (find-library name))))) >> + (lambda _ >> + ;; Those are safe to skip. >> + (format (current-error-port) >> + "warning: failed to substitute: ~a~%" >> + file)))) > > What often works in such cases is to force ISO-8859-1 encoding > (“Latin-1”), which is a “catch-all” encoding (it’s an 8-bit encoding > that covers the 256 values): > > (with-fluids ((%default-port-encoding "ISO-8859-1")) > (substitute* file-in-arbitrary-ascii-compatible-encoding > …)) >
Yeah, I tried that, but it was also producing 'encoding-error' in the builder, so I gave up it. It seems that's because the locale is "C" when calling `substitute*', and the files have UTF-8 copyright sign (©). But out of the builder, the `substitute*' works fine even with '(setlocale LC_ALL "C")'. Here is an example: --8<---------------cut here---------------start------------->8--- (use-modules (guix packages) (guix build-system gnu)) (package (name "test") (version "0") (source #f) (build-system gnu-build-system) (arguments '(#:phases (modify-phases %standard-phases (replace 'unpack (lambda _ (setlocale LC_ALL "en_US.utf8") (call-with-output-file "test" (lambda (port) (display "©" port))) (setlocale LC_ALL "C") (with-fluids ((%default-port-encoding #f)) (substitute* "test" (("t") "")))))))) (home-page #f) (synopsis #f) (description #f) (license #f)) --8<---------------cut here---------------end--------------->8---