<?php
// $Id: language_convert.php,v 1.3 2005/10/28 11:56:06 ohwada Exp $

// 2005-01-20 K.OHWADA
// add get_country() get_google_url()

// 2004-10-24 K.OHWADA
// utf8
// shorten_text

//=========================================================
// class language_convert
// created since v0.7
// porting form XFsection
// 2004/08/10 K.OHWADA
//=========================================================

class language_convert extends language_base
{

//---------------------------------------------------------
// constructor
//---------------------------------------------------------
function language_convert()
{
	language_base::language_base();
}

//---------------------------------------------------------
// function
//---------------------------------------------------------
function convert_telafriend_subject($text)
{
	return $this->convert_sjis_win_mac($text);
}

function convert_telafriend_body($text)
{
	return $this->convert_sjis_win_mac($text);
}

function convert_download_filename($text)
{
	return $this->convert_sjis_win_mac($text);
}

function convert_sjis_win_mac($text)
{
	if (($this->os == 'win')||($this->os == 'mac'))
	{	$text = mb_convert_encoding($text, 'SJIS', 'EUC-JP');	}

	return $text;	
}

// for search
function convert_space_zen_to_han($text)
{
	return mb_convert_kana($text, "s");
}

// utf8
function convert_from_utf8($text)
{
	return mb_convert_encoding($text, 'EUC-JP', 'UTF-8');
}

function convert_to_utf8($text)
{
	return mb_convert_encoding($text, 'UTF-8', 'EUC-JP');
}

function convert_encode_to_utf8($text, $encode)
{
	if ( empty($encode) )  return $text;
	if ( strtoupper($encode) == "UTF-8" )  return $text;

	return	$text = mb_convert_encoding($text, 'UTF-8', $encode);
}

// shorten_text
function shorten_text($text,$max)
{
	if ( strlen($text) > $max)
	{
		$text = mb_strimwidth( $text, 0, $max, " ..." );
	}

	return $text;
}

function send_mail($mailto, $subject, $body, $header)
{
	return mb_send_mail($mailto, $subject, $body, $header);
}

function get_country()
{
	return "japan";
}

function get_google_url()
{
	return "http://www.google.co.jp/search?hl=ja&amp;q=";
}

function get_happy_linux_url()
{
	return "http://linux.ohwada.jp/";
}

// --- class end ---
}

?>