| @@ -202,11 +202,12 @@ | ||
| 202 | 202 | // Trim and limit length for AI processing |
| 203 | 203 | $content = trim($content); |
| 204 | 204 | $max_length = 4000; // Reasonable limit for AI processing |
| 205 | 205 | |
| 206 | - if (strlen($content) > $max_length) { | |
| 207 | - $content = substr($content, 0, $max_length) . '...'; | |
| 208 | - } | |
| 206 | + // strlen()/substr() count BYTES: on Thai or CJK this handed the model a | |
| 207 | + // third of the intended content, and cut the last character in half so | |
| 208 | + // the payload carried an invalid UTF-8 sequence (#687). | |
| 209 | + $content = \ThinkRank\Core\Seo_Text::trim_to_length($content, $max_length); | |
| 209 | 210 | |
| 210 | 211 | return $content; |
| 211 | 212 | } |
| 212 | 213 | |