RenderableString should support encoding settings #42

Closed
cescoffier opened this Issue Nov 29, 2013 · 2 comments

Comments

Projects
None yet
2 participants
@cescoffier
Member

cescoffier commented Nov 29, 2013

No description provided.

@nicolas-rempulski

This comment has been minimized.

Show comment
Hide comment
@nicolas-rempulski

nicolas-rempulski Apr 7, 2014

Member

I'm not sure it is what you meant, but while implementing content compression, I added the support of result.getCharset() in the RenderableString.

It is now

public InputStream render(Context context, Result result) throws RenderableException {
        byte[] bytes;

        // We have a result, charset have to be provided
        if (result != null) {
            if (result.getCharset() == null) {
                // No charset provided, use default encoding.
                result.with(Charset.defaultCharset());
            }
            bytes = rendered.getBytes(result.getCharset());
        } else {
            //No Result, use the default platform encoding
            bytes = rendered.getBytes(Charset.defaultCharset());
        }

        return new ByteArrayInputStream(bytes);
    }

Instead of

    @Override
    public InputStream render(Context context, Result result) throws Exception {
        return new ByteArrayInputStream(rendered.getBytes());
    }
Member

nicolas-rempulski commented Apr 7, 2014

I'm not sure it is what you meant, but while implementing content compression, I added the support of result.getCharset() in the RenderableString.

It is now

public InputStream render(Context context, Result result) throws RenderableException {
        byte[] bytes;

        // We have a result, charset have to be provided
        if (result != null) {
            if (result.getCharset() == null) {
                // No charset provided, use default encoding.
                result.with(Charset.defaultCharset());
            }
            bytes = rendered.getBytes(result.getCharset());
        } else {
            //No Result, use the default platform encoding
            bytes = rendered.getBytes(Charset.defaultCharset());
        }

        return new ByteArrayInputStream(bytes);
    }

Instead of

    @Override
    public InputStream render(Context context, Result result) throws Exception {
        return new ByteArrayInputStream(rendered.getBytes());
    }
@cescoffier

This comment has been minimized.

Show comment
Hide comment
@cescoffier

cescoffier Apr 7, 2014

Member

Yes, that’s what I meant.

On 7 avr. 2014, at 12:01, Nicolas Rempulski notifications@github.com wrote:

I'm not sure it is what you meant, but while implementing content compression, I added the support of result.getCharset() in the RenderableString.

It is now

public InputStream render(Context context, Result result) throws RenderableException {
byte[] bytes;

    // We have a result, charset have to be provided
    if (result != null) {
        if (result.getCharset() == null) {
            // No charset provided, use default encoding.
            result.with(Charset.defaultCharset());
        }
        bytes = rendered.getBytes(result.getCharset());
    } else {
        //No Result, use the default platform encoding
        bytes = rendered.getBytes(Charset.defaultCharset());
    }

    return new ByteArrayInputStream(bytes);
}

Instead of

@Override
public InputStream render(Context context, Result result) throws Exception {
    return new ByteArrayInputStream(rendered.getBytes());
}


Reply to this email directly or view it on GitHub.

Member

cescoffier commented Apr 7, 2014

Yes, that’s what I meant.

On 7 avr. 2014, at 12:01, Nicolas Rempulski notifications@github.com wrote:

I'm not sure it is what you meant, but while implementing content compression, I added the support of result.getCharset() in the RenderableString.

It is now

public InputStream render(Context context, Result result) throws RenderableException {
byte[] bytes;

    // We have a result, charset have to be provided
    if (result != null) {
        if (result.getCharset() == null) {
            // No charset provided, use default encoding.
            result.with(Charset.defaultCharset());
        }
        bytes = rendered.getBytes(result.getCharset());
    } else {
        //No Result, use the default platform encoding
        bytes = rendered.getBytes(Charset.defaultCharset());
    }

    return new ByteArrayInputStream(bytes);
}

Instead of

@Override
public InputStream render(Context context, Result result) throws Exception {
    return new ByteArrayInputStream(rendered.getBytes());
}


Reply to this email directly or view it on GitHub.

@nicolas-rempulski nicolas-rempulski added this to the 0.5 milestone Apr 9, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment