backport: https://github.com/apache/doris/pull/50085
This commit is contained in:
@ -19,6 +19,7 @@ package org.apache.doris.nereids.trees.expressions.literal;
|
||||
|
||||
import org.apache.doris.nereids.types.DataType;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
@ -46,7 +47,7 @@ public abstract class StringLikeLiteral extends Literal {
|
||||
* get double value
|
||||
*/
|
||||
public static double getDouble(String str) {
|
||||
byte[] bytes = str.getBytes();
|
||||
byte[] bytes = str.getBytes(StandardCharsets.UTF_8);
|
||||
long v = 0;
|
||||
int pos = 0;
|
||||
int len = Math.min(bytes.length, 7);
|
||||
|
||||
@ -31,4 +31,11 @@ public class StringLikeLiteralTest {
|
||||
double d2 = StringLikeLiteral.getDouble(maxStr);
|
||||
Assertions.assertTrue(d1 < d2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUtf8() {
|
||||
System.setProperty("file.encoding", "ANSI_X3.4-1968");
|
||||
double d1 = StringLikeLiteral.getDouble("一般风险准备");
|
||||
Assertions.assertEquals(d1, 6.4379158486625512E16);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user