9

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?

2
  • What happens if you remove the % Encoding: UTF-8 and the subsequent blank lines?
    – Mico
    Apr 25, 2020 at 8:33
  • 1
    Oh great, that solved it. I think those lines were inserted by JabRef. Thanks!
    – Nereus
    Apr 25, 2020 at 8:43

3 Answers 3

8

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.

1
  • I had some "comments" starting with // inside my .bib file. Deleting or changing this to % solved the warning for me. Oct 12, 2021 at 7:55
2

I had a similar issue and couldn't find any answer, even with an Unicode converter.

What did the trick was to delete a hidden symbol right in front of the "@article".

1
  • 2
    Welcome to TeX.SE :) // As a hint, next time your remark should be a comment: "answers" are considered being "solutions" here. It's a bit different than in other forum groups ;-)
    – MS-SPO
    Sep 29, 2021 at 16:40
0

Here's a script to print lines with non-ascii characters in them. It assumes that the line can be decoded using UTF-8:

import sys

with open(sys.argv[1], 'rb') as f:
    data = f.readlines()

for n, line in enumerate(data):
    try:
        line.decode('ascii')
    except UnicodeDecodeError as e:
        line = line.decode('utf-8')
        print(f'{n}: {line}')
        print(f'  ^-- {e}')

Usage: python3 nonascii.py filename.bib

3
  • 2
    I'm not sure your answer is very helpful here. This is not an encoding problem since biber manages the utf-8 very well. Nov 2, 2021 at 23:57
  • Ordinarily the "characters of junk" message should not arise due to incorrect file encoding and generally non-ASCII characters are fine for Biber. In particular Biber can deal with UTF-8 and will issue a more specific error message if the .bib file encoding does not match the expected encoding.
    – moewe
    Nov 3, 2021 at 6:23
  • 2
    This is meant to be a simpler version of the accepted answer, which links to a website that is no longer available. If someone wants to post a new answer which figures out where extra characters occur, that would be helpful. Nov 4, 2021 at 0:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .