lucky13 Posted February 16, 2015 Share Posted February 16, 2015 Im building a web app using php and i have to count the words of an uploaded .doc or .docx file. So far im using the above functions in order to count the words but this code in not working for greek characters for .doc public static function docWordCount($file){ $fileHandle = fopen($file, "r"); $line = @fread($fileHandle, filesize($file)); $lines = explode(chr(0x0D),$line); $outtext = ""; foreach($lines as $thisline) { $pos = strpos($thisline, chr(0x00)); if (($pos !== FALSE)||(strlen($thisline)==0)) { } else { $outtext .= $thisline." "; } } $outtext = preg_replace("/[^a-zA-Z0-9\s\,\.\-\n\r\t@\/\_\(\)]/","",$outtext); return str_word_count($outtext); } If i use it with a .doc with greek characters i get an output this in the $outtext: _ÐTµ½S1£÷êù÷¯ž?EÇž?øéøáÃã?ZBΪmœ„åU/¿ýìÏÇ£? Quote Link to comment https://forums.phpfreaks.com/topic/294645-count-words-in-docdocx-with-greek-unicode-characters/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.