Verified Owner
Top Fields Constructors Methods
org.jabref.logic.integrity

public Class UTF8Checker

extends Object
implements EntryChecker
Class Inheritance
All Implemented Interfaces
org.jabref.logic.integrity.EntryChecker
Imports
java.nio.ByteBuffer, java.nio.charset.CharacterCodingException, .Charset, .CharsetDecoder, .StandardCharsets, java.util.ArrayList, .List, .Map, org.jabref.logic.l10n.Localization, org.jabref.model.entry.BibEntry, org.jabref.model.entry.field.Field

Field Summary

Modifier and TypeField and Description
private final Charset

Constructor Summary

AccessConstructor and Description
public
UTF8Checker(Charset
the charset used to decode BibEntry fields
charset
)

Creates a UTF8Checker that,

  1. decode a String into a bytes array
  2. attempts to decode the bytes array to a character array using the UTF-8 Charset

Method Summary

Modifier and TypeMethod and Description
public List<IntegrityMessage>

Returns:

return the warning of UTF-8 check for BibLatex.
check
(BibEntry
the BibEntry of BibLatex.
entry
)

Implements org.jabref.logic.integrity.EntryChecker.check.

Detect any non UTF-8 encoded field

public static boolean

Returns:

true if is encoded in UTF-8 and false is not encoded in UTF-8
UTF8EncodingChecker
(byte[]
the byte array used to check the encoding charset
data
)

Check whether a byte array is encoded in UTF-8 charset.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

charsetback to summary
private final Charset charset

Constructor Detail

UTF8Checkerback to summary
public UTF8Checker(Charset charset)

Creates a UTF8Checker that,

  1. decode a String into a bytes array
  2. attempts to decode the bytes array to a character array using the UTF-8 Charset
Parameters
charset:Charset

the charset used to decode BibEntry fields

Method Detail

checkback to summary
public List<IntegrityMessage> check(BibEntry entry)

Implements org.jabref.logic.integrity.EntryChecker.check.

Detect any non UTF-8 encoded field

Parameters
entry:BibEntry

the BibEntry of BibLatex.

Returns:List<IntegrityMessage>

return the warning of UTF-8 check for BibLatex.

Annotations
@Override
UTF8EncodingCheckerback to summary
public static boolean UTF8EncodingChecker(byte[] data)

Check whether a byte array is encoded in UTF-8 charset.

Use java api decoder and try&catch block to check the charset.

Parameters
data:byte[]

the byte array used to check the encoding charset

Returns:boolean

true if is encoded in UTF-8 and false is not encoded in UTF-8