在html Gmail/Android chrome中替换+ with space

Nom*_*man 6 html mailto gmail android google-chrome

嗨,我有使用mailto喜欢的web应用程序

<a href="mailto:someone@example.com?subject=This%20is%20the%20subject&amp;cc=someone_else@example.com&amp;body=This%20is%20the%20body" class="">Send email</a>
Run Code Online (Sandbox Code Playgroud)

但没有米,我做它总是用+号代替空间 图片

小智 1

尝试解码你的字符串

只需使用Uri.encode(String)。

subject = (EditText) findViewById(R.id.subject);
subject.setText(Uri.encode(WhatEverYourStringVarIs));
Run Code Online (Sandbox Code Playgroud)

这将帮助您解码 URIencode。

如果您指的是 PHP (HTML) 问题,请执行相同的操作:

$encodeString = urlencode($encodeString);
echo $encodedString;
Run Code Online (Sandbox Code Playgroud)

这样字符串就会正确显示。请参阅此url 编码。

好的,但是当我第三次阅读你的问题时:你可以在这些 HTML 情况下使用空格。这是一个 Android 错误。只需使用这个:

<a href="mailto:someone@example.com?subject=This is the subject&amp;cc=someone_else@example.com">Send Mail</a>
Run Code Online (Sandbox Code Playgroud)