Contents [hide]
输出结果
%BC%D6 車
程式码
JavaScript
1 2 3 4 5 6 7 | const iconv = require( 'iconv-lite' ) const fs = require( "fs" ); let utf8str = "車" let eucbuffer = iconv.encode(utf8str, 'eucjp' ) console.log( [...eucbuffer ].map(n => `%${n.toString(16).toUpperCase()}`).join( "" ) ) utf8str = iconv.decode(eucbuffer, 'eucjp' ) console.log(utf8str) |
PHP
1 2 3 4 5 6 7 | <?php $utf8str = "車" ; $eucstr = mb_convert_encoding( $utf8str , 'euc-jp' , 'utf8' ); print rawurlencode( $eucstr ). "\n" ; $utf8str = $eucstr ; $utf8str = mb_convert_encoding( $utf8str , 'utf8' , 'euc-jp' ); print $utf8str . "\n" ; |
Perl
1 2 3 4 5 6 7 8 9 | use Encode::EUCJPMS; use URI::Escape; my $utf8str = "車" ; my $eucstr = $utf8str ; Encode::from_to( $eucstr , "utf8" , "eucjp-ms" ); print uri_escape( $eucstr ). "\n" ; $utf8str = $eucstr ; Encode::from_to( $utf8str , "eucjp-ms" , "utf8" ); print ( $utf8str . "\n" ); |
Python
1 2 3 4 5 | import urllib.parse utf8str = "車" eucstr = utf8str.encode( 'euc-jp' ) print (urllib.parse.quote(eucstr)) print (eucstr.decode( 'euc-jp' )) |
Ruby
1 2 3 4 5 6 | require 'uri' utfstr = "車" eucstr = utfstr.encode( "EUC-JP" ) print( URI .escape(eucstr)+ "\n" ) utfstr = eucstr.encode( "UTF-8" , "EUC-JP" ) print(utfstr+ "\n" ) |
作者: 栗田 創。1st Class, inc的首席执行官/首席技术官。搜索引擎工程师、网站管理员
证书: AWS Solution Architect,Professional Scrum Master I ,一级IT工程师(日本国家证书),TOEIC900+,东京大学経済学部経営学科卒业
请关注我的Weblio帐户以获取更新
IT相关服务:VPS排名