简体   繁体   中英

Issue in encoding percent value

I'm encoding a URL string with % value in it.

URL string - Nanoparticles with 70 % Photoluminescence

but it's getting converted to

Nanoparticles%20with%2070%E2%80%89%25%20Photoluminescence and clicking on this is resulting a 404 page.

Could you please let me know how to escape these % values from encoding??

%E2%80%89 is Unicode character THIN SPACE, which means that the space between 70 and % is not a normal space ( %20 ).

You'll either have to fix the space manually (just delete it and press spacebar), or if you can't do that, you need to replace it with a normal space programmatically before encoding:

encodeURI( 'Nanoparticles with 70 % Photoluminescence'.replace( /\u2009/g, ' ' ) );

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