Skip to content

Commit 3a6288a

Browse files
committed
Fix PHP deprecation error for utf8_encode.
1 parent 75f435e commit 3a6288a

File tree

6 files changed

+17
-15
lines changed

6 files changed

+17
-15
lines changed

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
"require" : {
2020
"php" : ">=7.0",
2121
"ext-json" : "*",
22-
"ext-curl" : "*"
22+
"ext-curl" : "*",
23+
"ext-curl" : "*",
24+
"ext-mbstring": "*"
2325
},
2426
"require-dev" : {
2527
"phpunit/phpunit" : ">=5.7"

src/com/zoho/crm/api/Initializer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ private function getEncodedKey($user, $environment)
343343

344344
$key = explode("@", $userMail)[0] . $environment->getUrl();
345345

346-
$input = unpack('C*', utf8_encode($key));
346+
$input = unpack('C*', mb_convert_encoding($key, 'UTF-8'));
347347

348348
return base64_encode(implode(array_map("chr", $input)));
349349
}

src/com/zoho/crm/api/util/Converter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ public function getEncodedFileName()
274274

275275
$fileName = explode("@",$fileName)[0] . Initializer::getInitializer()->getEnvironment()->getUrl();
276276

277-
$input = unpack('C*', utf8_encode($fileName));
277+
$input = unpack('C*', mb_convert_encoding($fileName, 'UTF-8'));
278278

279279
$str = base64_encode(implode(array_map("chr", $input)));
280280

src/com/zoho/crm/api/util/FormDataConverter.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,11 @@ public function appendToRequest(&$requestBase, $requestObject)
109109

110110
$date = new \DateTime();
111111

112-
$data = utf8_encode($lineEnd);
112+
$data = mb_convert_encoding($lineEnd, 'UTF-8');
113113

114114
$current_time_long = $date->getTimestamp();
115115

116-
$boundaryStart = utf8_encode($hypen.(string)$current_time_long.$lineEnd);
116+
$boundaryStart = mb_convert_encoding($hypen.(string)$current_time_long.$lineEnd, 'UTF-8');
117117

118118
for ($i = 0; $i < sizeof($keysDetail); $i++)
119119
{
@@ -129,14 +129,14 @@ public function appendToRequest(&$requestBase, $requestObject)
129129

130130
$contentDisp = "Content-Disposition: form-data; name=\"".$key."\";filename=\"".$fileName."\"".$lineEnd.$lineEnd;
131131

132-
$data = $data.utf8_encode($contentDisp);
132+
$data = $data.mb_convert_encoding($contentDisp, 'UTF-8');
133133

134-
$data = $data.$fileData.utf8_encode($lineEnd);
134+
$data = $data.$fileData.mb_convert_encoding($lineEnd, 'UTF-8');
135135
}
136136
}
137137
$boundaryend = $hypen . (string)$current_time_long . $hypen . $lineEnd . $lineEnd;
138138

139-
$data = $data . utf8_encode($boundaryend);
139+
$data = $data . mb_convert_encoding($boundaryend, 'UTF-8');
140140

141141
$header = ['ENCTYPE: multipart/form-data','Content-Type:multipart/form-data;boundary=' . (string)$current_time_long];
142142

@@ -160,19 +160,19 @@ public function appendToRequest(&$requestBase, $requestObject)
160160

161161
$header = ['ENCTYPE: multipart/form-data','Content-Type:multipart/form-data;boundary='.(string)$current_time_long];
162162

163-
$data = utf8_encode($lineEnd);
163+
$data = mb_convert_encoding($lineEnd, 'UTF-8');
164164

165-
$boundaryStart = utf8_encode($hypen.(string)$current_time_long.$lineEnd) ;
165+
$boundaryStart = mb_convert_encoding($hypen.(string)$current_time_long.$lineEnd, 'UTF-8') ;
166166

167167
$data = $data.$boundaryStart;
168168

169-
$data = $data.utf8_encode($contentDisp);
169+
$data = $data.mb_convert_encoding($contentDisp, 'UTF-8');
170170

171-
$data = $data.$fileData.utf8_encode($lineEnd);
171+
$data = $data.$fileData.mb_convert_encoding($lineEnd, 'UTF-8');
172172

173173
$boundaryend = $hypen.(string)$current_time_long.$hypen.$lineEnd.$lineEnd;
174174

175-
$data = $data.utf8_encode($boundaryend);
175+
$data = $data.mb_convert_encoding($boundaryend, 'UTF-8');
176176

177177
$requestBase[CURLOPT_HTTPHEADER] = $header;
178178

src/com/zoho/crm/api/util/ModuleFieldsHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ private static function getFileName()
2929

3030
$fileName = explode("@", $fileName)[0] . Initializer::getInitializer()->getEnvironment()->getUrl();
3131

32-
$input = unpack('C*', utf8_encode($fileName));
32+
$input = unpack('C*', mb_convert_encoding($fileName, 'UTF-8'));
3333

3434
return base64_encode(implode(array_map("chr", $input)));
3535
}

src/com/zoho/crm/api/util/Utility.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ private static function getFileName()
316316

317317
$fileName = explode("@", $fileName)[0] . Initializer::getInitializer()->getEnvironment()->getUrl();
318318

319-
$input = unpack('C*', utf8_encode($fileName));
319+
$input = unpack('C*', mb_convert_encoding($fileName, 'UTF-8'));
320320

321321
$str = base64_encode(implode(array_map("chr", $input)));
322322

0 commit comments

Comments
 (0)