Biblatex Biber – How to Fix Junk Characters in .bib File

biberbiblatex

I'm using a .bib file to list my references. When I run Biber in TeXstudio the references compile correctly, but I get the following warning:

WARN - BibTeX subsystem: C:\Users\[user]\AppData\Local\Temp\biber_tmp_WQTH\thesis_references.bib_15484.utf8, line 4, warning: 3 characters of junk seen at toplevel

I've taken a look at the .bib file and have looked for problematic characters, but I can't see anything that might be causing the error. I've also tried to replace the top reference which might contain the error, but it didn't help. The file mentioned in the warning appears to be some kind of temporary file which disappears again after compilation (?).

This is what my .bib file looks like:

% Encoding: UTF-8


@article{aguzzi2013microglia,
    title={Microglia: scapegoat, saboteur, or something else?},
    author={Aguzzi, Adriano and Barres, Ben A and Bennett, Mariko L},
    journal={Science},
    volume={339},
    number={6116},
    pages={156--161},
    year={2013},
    publisher={American Association for the Advancement of Science}
}
etc.

Am I missing something?

Best Answer

If you copy-and-paste your code into a Unicode converter such that https://w3c.github.io/xml-entities/unicode-names.html you will find that you have an invisible

U+feff ZERO WIDTH NO-BREAK SPACE

in the line after the comment. Since that invisible character is not hidden from Biber with a comment character, it produces this harmless warning. (Like BibTeX Biber ignores text outside of entries. But unlike BibTeX Biber warns about possible junk characters unless the text outside of entries is marked as a comment with %. BibTeX does not recognise % as a comment character. See code comments in a biblatex file, Are comments discouraged in a BibTeX file?, Comment out sections of text in bib file.)

You can always choose to ignore Biber's "junk character" warnings, they are just a sign that something might be wrong in your .bib, like a missing or spurious brace or comma. But it need not mean anything bad. Usually you'll get a hard error if something is really wrong.

The trick is to remove the invisible character

% Encoding: UTF-8

@article{aguzzi2013microglia,
  title   = {Microglia: scapegoat, saboteur, or something else?},
  author  = {Aguzzi, Adriano and Barres, Ben A. and Bennett, Mariko L.},
  journal = {Science},
  volume  = {339},
  number  = {6116},
  pages   = {156--161},
  year    = {2013},
}

Biber will not complain about the comment per se.

Note that it is usually better to end given name initials with a dot instead of just giving the letter.

Related Question