Bug 42887 - Encoding iso-8859-1 throws IndexOutOfRangeException for Unicode surrogate pairs
Summary: Encoding iso-8859-1 throws IndexOutOfRangeException for Unicode surrogate pairs
Alias: None
Product: Class Libraries
Classification: Mono
Component: System (show other bugs)
Version: 4.4.0 (C7)
Hardware: All Linux
: --- normal
Target Milestone: 4.6.0 (C8)
Assignee: Alexander Köplinger [MSFT]
Depends on:
Reported: 2016-07-28 14:51 UTC by Lukas Matyska
Modified: 2016-09-01 06:07 UTC (History)
3 users (show)

See Also:
Is this bug a regression?: Yes
Last known good build:


Description Lukas Matyska 2016-07-28 14:51:31 UTC
Description of Problem:
The IndexOutOfRangeException is thrown when calling:
where input contains Unicode surrogate pair, such as smiley.

Steps to reproduce the problem:
1. call this Encoding.GetEncoding("iso-8859-1").GetBytes("\ud83d\ude0a ");

Actual Results:
IndexOutOfRangeException is thrown

Expected Results:
No exception is thrown; three bytes are returned.

How often does this happen? 
Comment 1 Lukas Matyska 2016-07-28 14:57:38 UTC
This BUG is new to Mono version 4.

I have tested this on Mono and 3.2.8 (Debian) without exception.
The exception was risen on Mono 4.4.1.
Comment 2 Alexander Köplinger [MSFT] 2016-08-30 18:31:44 UTC
Thank you for the bug report!

I implemented a fix in this pull request: https://github.com/mono/mono/pull/3489
Comment 3 Alexander Köplinger [MSFT] 2016-08-31 22:48:19 UTC
This was merged to mono master/4b5eace32dc2c6353425f9ee75299b7fc3e43e02 and mono-4.6.0-branch/50e81ed6e587222f9af6b9d372ea7f798e145236

Note You need to log in before you can comment on or make changes to this bug.