I want to send a Unicode string as a request parameter like this:
{"mobile": "۹۸.۹۱۲۳۴۳۰۴۱۲"}
but Karate send it like this instead:
{"mobile": "??.??????????"}
I've tried to read Unicode text from a file contains my text:
۹۸.۹۱۲۳۴۳۰۴۱۲
then read and send it this way:
* def persianMobile1 = read('classpath:account/unicode/persian.mobile.txt')
Given url karate.get('urlBase') + "account/activateMobileByVerificationCode"
And request
"""
{
"mobile":#(persianMobile1),
"code":#(defaultVerificationCode)
}
"""
Same problem occurred. What should I do?
Set the maven-surefire-plugin
in your pom.xml
to use the UTF-8
file encoding. Add this <plugin>
if it is not there already.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.10</version>
<configuration>
<argLine>-Dfile.encoding=UTF-8</argLine>
</configuration>
</plugin>
EDIT: looks like OP is using Gradle. You need to get Karate (which I assume is run via JUnit) to have the JVM file.encoding set to UTF-8 - to fix this.
Here is a link that should help you do this in Gradle: https://discuss.gradle.org/t/no-possibility-to-set-file-encoding-for-junit-tests-in-gradle-2-13-and-odler/17223
I suggest you work with a Java dev if you need to.