在php中,怎样把字符串转为UTF
答案:1 悬赏:20 手机版
解决时间 2021-03-09 06:51
- 提问者网友:星軌
- 2021-03-08 17:11
在php中,怎样把字符串转为UTF
最佳答案
- 五星知识达人网友:零点过十分
- 2021-03-08 18:49
test.php
<?php
$a = '在php中';
$a = unpack('C*', $a);
var_dump(array_values($a));
Test.java
import java.io.*;
public class Test{
public static void main(String args[]){
String Str1 = new String("在php中");
try{
byte[] bytes = Str1.getBytes("UTF-8");
StringBuilder sb = new StringBuilder();
for (byte b : bytes) {
sb.append(String.format("%d ", b & 0xff));
}
System.out.println(sb.toString());
}catch( UnsupportedEncodingException e){
System.out.println("Unsupported character set");
}
}
}
<?php
$a = '在php中';
$a = unpack('C*', $a);
var_dump(array_values($a));
Test.java
import java.io.*;
public class Test{
public static void main(String args[]){
String Str1 = new String("在php中");
try{
byte[] bytes = Str1.getBytes("UTF-8");
StringBuilder sb = new StringBuilder();
for (byte b : bytes) {
sb.append(String.format("%d ", b & 0xff));
}
System.out.println(sb.toString());
}catch( UnsupportedEncodingException e){
System.out.println("Unsupported character set");
}
}
}
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯