So I have a form that when submitted by iPhone, if the user enters ’ it is entered in the database at ’.
I'm wondering if there is a way to convert this to a single character before entering it into the database. The main reason I need this is because it is being sent out as a txt message and every character counts.
I'd like to know if there is a function to convert these characters
— enters as — convert to -
– enters as — convert to -
“ enters as “ convert to "
” enters as †convert to "
‘ enters as ‘ convert to '
’ enters as ’ convert to '
The problem really is not that it's stored that way in the database, but rather when the txt message is sent pulling data from the database.
In further testing, eliminating the database, did a test with a form submitting to php and emailing to sms gateway, when using phone to enter characters such as “ ” do not go through in the txt message, so this make me think that they are becoming mojibake. I have set in the page with the form.
Here is another illustration that demonstrates the problem. Here an iPhone (6s iO2 11.2.2 safari) submitting text to a php script which emails to an sms gateway, the text comes through without the special characters (“ ” ‘ ’), instead those characters are shown with a b, example text sent as “test” ‘test’ will come through in the txt as btestb btestb. Below is the ultra simple code that reproduces this issue.
filename: sms.php (using php 7.1.13)
<?
if(isset($_POST['sub'])){
$data = isset($_POST['data'])?$_POST['data']:NULL;
if($data){
if(mail('5555555555@messaging.sprintpcs.com','',$data,'From: name@somedomain.com')){
echo 'sent!';
};
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>test</title>
<meta charset="UTF-8" />
<meta content="minimum-scale=1.0, width=device-width, maximum-scale=1, user-scalable=no" name="viewport">
</head>
<body>
<form action="sms.php" method="post" />
<input label="enter txt here" value="" name="data" />
<input type="submit" value="go" name="sub" />
</form>
</body>
</html>
- use an iPhone to enter the following characters “ ” ‘ ’