• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
avoid ?utf-8?Q? in subject line

#1
[eluser]padmapriya[/eluser]
Hi,

Am using codeigniter 2.1.

How to avoid ?utf-8?Q? in subject line. Here is example am facing (?UTF-8?Q?App Confirmed?=)
How can i avoid this in Subject line for mobile sms..
For Email am getting correct Subject.


1.I have tried using the Email.php

var $newline = "\r\n";
var $crlf = "\r\n";

2.Tried for string replace also..

But no luck.. Same error..
Please,let me know the Process to avoid this error.

#2
[eluser]yacman[/eluser]
Try
Code:
$config['charset'] = "utf-8";

#3
[eluser]padmapriya[/eluser]
Hi All,
Here is the Path System/libraries/Email.php
It Worked for me by Avoid ?utf-8?Q? in subject line

Do following Comments in the Function below to avoid the special Characters..

/*Commented by Priya for SMS Subject Format to Avoid ?utf-8?Q? in subject line*/
//$char = '='.dechex($ascii);

/*Commented by Priya for SMS Subject Format to Avoid ?utf-8?Q? in subject line*/
//$char = '_';

/*Commented by Priya for SMS Subject Format to Avoid ?utf-8?Q? in subject line*/

//$str = trim(preg_replace('/^(.*)$/m', ' =?'.$this->charset.'?Q?$1?=', $str));


******************************************************************************************
private function _prep_q_encoding($str, $from = FALSE)
{
$str = str_replace(array("\r", "\n"), array('', ''), $str);

// Line length must not exceed 76 characters, so we adjust for
// a space, 7 extra characters =??Q??=, and the charset that we will add to each line
$limit = 75 - 7 - strlen($this->charset);

// these special characters must be converted too
$convert = array('_', '=', '?');

if ($from === TRUE)
{
$convert[] = ',';
$convert[] = ';';
}

$output = '';
$temp = '';

for ($i = 0, $length = strlen($str); $i < $length; $i++)
{
// Grab the next character
$char = substr($str, $i, 1);
$ascii = ord($char);

// convert ALL non-printable ASCII characters and our specials
if ($ascii < 32 OR $ascii > 126 OR in_array($char, $convert))
{
/*Commented by Priya for SMS Subject Format to Avoid ?utf-8?Q? in subject line*/
//$char = '='.dechex($ascii);
}

// handle regular spaces a bit more compactly than =20
if ($ascii == 32)
{
/*Commented by Priya for SMS Subject Format to Avoid ?utf-8?Q? in subject line*/
//$char = '_';
}

// If we're at the character limit, add the line to the output,
// reset our temp variable, and keep on chuggin'
if ((strlen($temp) + strlen($char)) >= $limit)
{
$output .= $temp.$this->crlf;
$temp = '';
}

// Add the character to our temporary line
$temp .= $char;
}

$str = $output.$temp;

// wrap each line with the shebang, charset, and transfer encoding
// the preceding space on successive lines is required for header "folding"

/*Commented by Priya for SMS Subject Format to Avoid ?utf-8?Q? in subject line*/

//$str = trim(preg_replace('/^(.*)$/m', ' =?'.$this->charset.'?Q?$1?=', $str));

return $str;
}

#4
[eluser]fuchong[/eluser]
Thank you for the code. This seemed to fix the ?UTF-8? issue for me when sending to sms via the email library.

Since this fix seems to require a modification to the email library would it be wise to open up a new issue in the Github issue tracker? After checking the issue tracker there doesn't seem to be anything that references this exact issue.

I also used this post http://ellislab.com/forums/viewthread/119946/ as a reference and the code submitted by takasia, which fixed the big. I found this thread through this issue#1409 - https://github.com/EllisLab/CodeIgniter/issues/1409 on GitHub.

The 1409 issue is tagged in an open pull request https://github.com/EllisLab/CodeIgniter/pull/1709 which I can confirm does not fix this issue.

I'm not sure what this code would effect as a whole, but I think that it might be worth bringing it to the attention of the devs.

#5
[eluser]Narf[/eluser]
Can you guys tell me if this one works for you? https://gist.github.com/3891474

More info: https://github.com/EllisLab/CodeIgniter/...nt-9330713

#6
[eluser]fuchong[/eluser]
@Narf - Yes that email library made it so that my SMS messages don't have the ?UTF-8? in the subject.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.