diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Text/Encoding.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Text/Encoding.enso index 4ad4cb1a0b4fd..1d7a70c13cf0b 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Text/Encoding.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Text/Encoding.enso @@ -9,7 +9,7 @@ polyglot java import org.enso.base.Text_Utils all_character_sets : Vector.Vector Text all_character_sets = java_array = Charset.availableCharsets.keySet.toArray - Vector.Vector java_array + Vector.from_polyglot_array java_array ## Get all available Encodings. all_encodings : Vector Encoding diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Text/Extensions.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Text/Extensions.enso index 347e796443478..431024be76af5 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Text/Extensions.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Text/Extensions.enso @@ -817,7 +817,7 @@ Text.from_utf_8 bytes on_problems=Report_Warning = "Hello".char_vector Text.char_vector : Vector.Vector Integer -Text.char_vector self = Vector.Vector (Text_Utils.get_chars self) +Text.char_vector self = Vector.from_polyglot_array (Text_Utils.get_chars self) ## Takes a vector of characters and returns the text that results from it. @@ -840,7 +840,7 @@ Text.from_char_vector chars = Text_Utils.from_chars chars.to_array "Hello".codepoints Text.codepoints : Vector.Vector Integer -Text.codepoints self = Vector.Vector (Text_Utils.get_codepoints self) +Text.codepoints self = Vector.from_polyglot_array (Text_Utils.get_codepoints self) ## Takes an array of numbers and returns the text resulting from interpreting it as a sequence of Unicode codepoints. diff --git a/engine/runtime-language-epb/src/main/java/org/enso/interpreter/epb/node/CoercePrimitiveNode.java b/engine/runtime-language-epb/src/main/java/org/enso/interpreter/epb/node/CoercePrimitiveNode.java index 2025308adc242..c36a2a4325707 100644 --- a/engine/runtime-language-epb/src/main/java/org/enso/interpreter/epb/node/CoercePrimitiveNode.java +++ b/engine/runtime-language-epb/src/main/java/org/enso/interpreter/epb/node/CoercePrimitiveNode.java @@ -64,6 +64,19 @@ long doInteger(Object integer, @CachedLibrary(limit = "5") InteropLibrary number } } + @Specialization(guards = {"characters.isString(character)", "isChar(character)"}) + long doChar(Object character, @CachedLibrary(limit = "5") InteropLibrary characters) { + try { + return characters.asString(character).charAt(0); + } catch (UnsupportedMessageException e) { + throw new IllegalStateException("Impossible, `character` is checked to be a long"); + } + } + + static boolean isChar(Object s) { + return s instanceof Character; + } + @Fallback Object doNonPrimitive(Object value) { return value;