< prev index next >

src/java.base/share/classes/java/lang/StringUTF16.java

Print this page
rev 49071 : [mq]: 4993841

*** 1,7 **** /* ! * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 233,242 **** --- 233,253 ---- byte[] result = new byte[2]; putChar(result, 0, c); return result; } + static byte[] toBytes(int cp) { + if (Character.isBmpCodePoint(cp)) { + return toBytes((char)cp); + } else { + byte[] result = new byte[4]; + putChar(result, 0, Character.highSurrogate(cp)); + putChar(result, 1, Character.lowSurrogate(cp)); + return result; + } + } + @HotSpotIntrinsicCandidate public static void getChars(byte[] value, int srcBegin, int srcEnd, char dst[], int dstBegin) { // We need a range check here because 'getChar' has no checks if (srcBegin < srcEnd) { checkBoundsOffCount(srcBegin, srcEnd - srcBegin, value);
< prev index next >