简体   繁体   中英

php turn words to full-width

Is there any method to change words to full-width like:

123 ->123

Because I have to turn Japanese words to full-width, I cannot use some way like enumeration. ( like: str_replace('1','1',$string); str_replace('2','2',$string); ... and so on.)

How do I solve the problem?

And, is it possible to force user typing full-width words?

My web is written in PHP, and I know how to combine with javascript.

The typing I already clarify is like:

onKeyUp="value=value.replace(/[\x00-\xff]/g,'')"

(The upper regular expression is enable user typing Japanese like 'カメラ', Chinese like '你好', and full-width words, that is what I want.)

But I don't know how to force the user typing full-width words; like can force user input English or numeric words.( Or it is impossible to do it)

Any replying appreciate!

There are several options to achieve this but I think the easiest is to use the kbd HTML tag:

<kbd>Some text in here</kbd>

You can also try an experimental CSS solution:

p {
  text-transform: full-width
}

Finally, try CSS letter-spacing to achieve a similar effect with the right font.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM