Merge branch 'master' into fix-47
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4d05935..797ea91 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,6 @@
-## 3.0.2-dev
+## 3.0.2
+
+* Fix bug in `CodePage` class. See issue [#47](https://github.com/dart-lang/convert/issues/47).
 
 ## 3.0.1
 
diff --git a/lib/src/codepage.dart b/lib/src/codepage.dart
index 376a9ec..cfc58db 100644
--- a/lib/src/codepage.dart
+++ b/lib/src/codepage.dart
@@ -262,7 +262,7 @@
       throw ArgumentError.value(
           characters, "characters", "Must contain 256 characters");
     }
-    result[i] = char;
+    result[i++] = char;
     allChars |= char;
   }
   if (i < 256) {
diff --git a/pubspec.yaml b/pubspec.yaml
index 11bf423..ad683ae 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
 name: convert
-version: 3.0.2-dev
+version: 3.0.2
 description: >-
   Utilities for converting between data representations.
   Provides a number of Sink, Codec, Decoder, and Encoder types.
diff --git a/test/codepage_test.dart b/test/codepage_test.dart
index 2105f27..e93ef30 100644
--- a/test/codepage_test.dart
+++ b/test/codepage_test.dart
@@ -60,4 +60,15 @@
     var decoded = latin3.decode(encoded, allowInvalid: true);
     expect(decoded, latin2text);
   });
+
+  test("Custom code page", () {
+    var cp = CodePage("custom", "ABCDEF" + "\uFFFD" * 250);
+    var result = cp.encode("BADCAFE");
+    expect(result, [1, 0, 3, 2, 0, 5, 4]);
+    expect(() => cp.encode("GAD"), throwsFormatException);
+    expect(cp.encode("GAD", invalidCharacter: 0x3F), [0x3F, 0, 3]);
+    expect(cp.decode([1, 0, 3, 2, 0, 5, 4]), "BADCAFE");
+    expect(() => cp.decode([6, 1, 255]), throwsFormatException);
+    expect(cp.decode([6, 1, 255], allowInvalid: true), "\u{FFFD}B\u{FFFD}");
+  });
 }