Skip to content

Npgsql-4.0.7 Copy Writer with emoji : Unable to translate unicode character \\uD83D at index 499 to specified code page #2751

@leafduan

Description

@leafduan

The issue

when using copy importer from binary to witer text column with emoji

before writer, substring(0, 500) for string

Exception message: Unable to translate Unicode character \\uD83D at index 499 to specified code page.
Stack trace:
at System.Text.EncoderExceptionFallbackBuffer.Fallback(Char charUnknown, Int32 index) 
at System.Text.EncoderFallbackBuffer.InternalFallback(Char ch, Char*& chars) 
at System.Text.UTF8Encoding.GetByteCount(Char* chars, Int32 count, EncoderNLS baseEncoder) 
at System.Text.UTF8Encoding.GetByteCount(String chars) 
at Npgsql.TypeHandlers.TextHandler.ValidateAndGetLength(String value, NpgsqlLengthCache& lengthCache, NpgsqlParameter parameter) 
at lambda_method(Closure , NpgsqlTypeHandler , Object , NpgsqlLengthCache& , NpgsqlParameter )
at Npgsql.NpgsqlParameter.ValidateAndGetLength()
at Npgsql.NpgsqlBinaryImporter.Write[T](T value, NpgsqlParameter param) // T is string

Further technical details

Npgsql version: 4.0.7
PostgreSQL version:

PostgreSQL 10.10 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36), 64-bit
LC_CTYPE=zh_CN.UTF-8
LC_COLLATE=zh_CN.UTF-8

Operating system (App):

CentOS Linux release 7.2.1511 (Core)
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions