Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
21ecd4db97 | |||
5ca28b28ef |
12
HISTORY
12
HISTORY
@@ -1,3 +1,15 @@
|
|||||||
|
0.4 - 2014-08-06
|
||||||
|
Replaced ucwords with ucfirst (and made a matching UTF-8
|
||||||
|
ucfirst function). When using ucwords it was not
|
||||||
|
possible to reach articles with names such as 'Computer
|
||||||
|
programming language' since it would uppercase all words.
|
||||||
|
Since the first letter is always upperace, ucfirst is
|
||||||
|
still safe.
|
||||||
|
|
||||||
|
0.3.1 - 2014-08-04
|
||||||
|
Minor changes, changed some variables to constant and
|
||||||
|
added a constant for the version number.
|
||||||
|
|
||||||
0.3 - 2014-08-04
|
0.3 - 2014-08-04
|
||||||
Added a check to see whatever the article string is in
|
Added a check to see whatever the article string is in
|
||||||
UTF-8 or not. If it is in UTF-8, use a specific function
|
UTF-8 or not. If it is in UTF-8, use a specific function
|
||||||
|
21
wie.php
21
wie.php
@@ -17,9 +17,10 @@
|
|||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
define("VERSION", "0.4");
|
||||||
|
define("PROGNAME", $argv[0]);
|
||||||
|
|
||||||
$defaultLang = "en"; // default language
|
$defaultLang = "en"; // default language
|
||||||
$progName = $argv[0];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -50,14 +51,14 @@ else
|
|||||||
$article = $argv[1];
|
$article = $argv[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if article is UTF-8 encoded, in which case regular ucwords won't work
|
// check if article is UTF-8 encoded, in which case regular ucfirst won't work
|
||||||
if (mb_check_encoding($article, 'UTF-8'))
|
if (mb_check_encoding($article, 'UTF-8'))
|
||||||
{
|
{
|
||||||
$article = utf8_ucwords($article); // uppercase article in UTF-8
|
$article = utf8_ucfirst($article); // uppercase article in UTF-8
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$article = ucwords($article); // uppercase article
|
$article = ucfirst($article); // uppercase article
|
||||||
}
|
}
|
||||||
|
|
||||||
$article = preg_replace("/\s/", "_" ,$article); // make spaces to underscore
|
$article = preg_replace("/\s/", "_" ,$article); // make spaces to underscore
|
||||||
@@ -85,17 +86,19 @@ print (wordwrap($string, 65, "\n") . "\n");
|
|||||||
// misc functions
|
// misc functions
|
||||||
function usage()
|
function usage()
|
||||||
{
|
{
|
||||||
print "Wikipedia ingress extractor (wie), version 0.2\n";
|
print "Wikipedia ingress extractor (wie), version " . VERSION . "\n";
|
||||||
print "Usage: $GLOBALS[progName] [--lang=sv] article\n";
|
print "Usage: " . PROGNAME . " [--lang=sv] article\n";
|
||||||
print "Default language if none specified is $GLOBALS[defaultLang].\n";
|
print "Default language if none specified is $GLOBALS[defaultLang].\n";
|
||||||
print "Remember to quote the article if there's more than one word,\n";
|
print "Remember to quote the article if there's more than one word,\n";
|
||||||
print "for example Roger Bacon as 'Roger Bacon'.\n";
|
print "for example Roger Bacon as 'Roger Bacon'.\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
function utf8_ucwords($str)
|
function utf8_ucfirst($str)
|
||||||
{
|
{
|
||||||
$str = mb_convert_case($str, MB_CASE_TITLE, "UTF-8");
|
$firstChar = mb_substr($str, 0, 1, 'UTF-8');
|
||||||
return $str;
|
$uc_str = mb_strtoupper($firstChar, 'UTF-8') . mb_substr($str, 1, NULL, 'UTF-8');
|
||||||
|
|
||||||
|
return $uc_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
Reference in New Issue
Block a user