Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package com.google.common.escape;

import static com.google.common.base.Preconditions.checkNotNull;
import static java.lang.Character.charCount;

import com.google.common.annotations.GwtCompatible;
import org.jspecify.annotations.Nullable;
Expand Down Expand Up @@ -134,7 +135,7 @@ protected int nextEscapeIndex(CharSequence csq, int start, int end) {
if (cp < 0 || escape(cp) != null) {
break;
}
index += Character.isSupplementaryCodePoint(cp) ? 2 : 1;
index += charCount(cp);
}
return index;
}
Expand Down Expand Up @@ -171,7 +172,7 @@ protected final String escapeSlow(String s, int index) {
// (for performance reasons) yield some false positives but it must never
// give false negatives.
char[] escaped = escape(cp);
int nextIndex = index + (Character.isSupplementaryCodePoint(cp) ? 2 : 1);
int nextIndex = index + charCount(cp);
if (escaped != null) {
int charsSkipped = index - unescapedChunkStart;

Expand Down
5 changes: 3 additions & 2 deletions guava/src/com/google/common/escape/UnicodeEscaper.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package com.google.common.escape;

import static com.google.common.base.Preconditions.checkNotNull;
import static java.lang.Character.charCount;

import com.google.common.annotations.GwtCompatible;
import org.jspecify.annotations.Nullable;
Expand Down Expand Up @@ -134,7 +135,7 @@ protected int nextEscapeIndex(CharSequence csq, int start, int end) {
if (cp < 0 || escape(cp) != null) {
break;
}
index += Character.isSupplementaryCodePoint(cp) ? 2 : 1;
index += charCount(cp);
}
return index;
}
Expand Down Expand Up @@ -171,7 +172,7 @@ protected final String escapeSlow(String s, int index) {
// (for performance reasons) yield some false positives but it must never
// give false negatives.
char[] escaped = escape(cp);
int nextIndex = index + (Character.isSupplementaryCodePoint(cp) ? 2 : 1);
int nextIndex = index + charCount(cp);
if (escaped != null) {
int charsSkipped = index - unescapedChunkStart;

Expand Down
Loading