- 
    Enhancement 
- 
    Resolution: Unresolved
- 
     P4 P4
- 
    None
- 
    None
- 
        generic
- 
        generic
                    Charsets which are prefixed by a BOM need to include the size of it into maxBytesPerChar() to fulfil bug JDK-8230531.
The downside is, that the buffer, calculated from maxBytesPerChar(), is near twice in size than needed.
With this new API, the actually needed buffer size could be calculated with:
int bufSize = encoder.minBytesPerSequence() + (encoder.maxBytesPerChar() - encoder.minBytesPerSequence()) * sequenceLength;
// or
int bufSize = encoder.maxBytesPerChar() * sequenceLength - encoder.minBytesPerSequence() * (sequenceLength - 1);
            
The downside is, that the buffer, calculated from maxBytesPerChar(), is near twice in size than needed.
With this new API, the actually needed buffer size could be calculated with:
int bufSize = encoder.minBytesPerSequence() + (encoder.maxBytesPerChar() - encoder.minBytesPerSequence()) * sequenceLength;
// or
int bufSize = encoder.maxBytesPerChar() * sequenceLength - encoder.minBytesPerSequence() * (sequenceLength - 1);
- relates to
- 
                    JDK-8230531 API Doc for CharsetEncoder.maxBytesPerChar() should be clearer about BOMs -           
- Closed
 
-         
- 
                    JDK-8262187 CharsetEncoder.maxBytesPerChar() and CharsetDecoder.maxCharsPerByte() return float instead of int -           
- Open
 
-