You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Duncan Jones (JIRA)" <ji...@apache.org> on 2016/12/17 22:59:58 UTC

[jira] [Commented] (LANG-1299) Add method for converting string to an array of code points

    [ https://issues.apache.org/jira/browse/LANG-1299?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15757763#comment-15757763 ] 

Duncan Jones commented on LANG-1299:
------------------------------------

Example implementation:

{code:java}
    public static int[] toCodePointArray(String s) {
        int[] result = new int[s.codePointCount(0, s.length())];
        int index = 0;
        for (int i = 0; i < result.length; i++) {
            result[i] = s.codePointAt(index);
            index += Character.charCount(result[i]);
        }     
        return result;
    }
{code}

> Add method for converting string to an array of code points
> -----------------------------------------------------------
>
>                 Key: LANG-1299
>                 URL: https://issues.apache.org/jira/browse/LANG-1299
>             Project: Commons Lang
>          Issue Type: Improvement
>          Components: lang.*
>    Affects Versions: 3.5
>            Reporter: Duncan Jones
>            Priority: Minor
>
> Java 7 doesn't offer a method for converting a string to an array of code points. This might be something we could add to {{StringUtils}}.
> {code:java}
> int[] codePoints = StringUtils.toCodePointArray(someString);
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)