formatter WxSendVoiceMsg to Json string
@param WxSendVoiceMsg $msg
@return string
175483
protected function sendVoiceMsgToJsonString(WxSendVoiceMsg $msg)
    {
        $formatStr = '{
                        "touser":"%s",
                        "msgtype":"%s",
                        "voice":
                        {
                          "media_id":"%s"
                        }
                    }';
        $result = sprintf($formatStr,   $msg->getToUserName(),
                                        $msg->getMsgType(),
                                        $msg->getMediaId()
                        );


        return $result;
    }
86643
private function one_line(string $msg) {
		$msg = trim($msg);
		$msg = str_replace([
			"\t", "\n", "\r",
		], [
			'\t', '\n', '\r',
		], $msg);
		return preg_replace('! +!', ' ', $msg);
	}
1060580
function formatMessage(msg) {
		var args = arguments;
		return msg.replace(/\$\{([^\}]+)\}/g, function(str, index) { return args[(index << 0) + 1]; });
	}
975614
protected function sendMusicMsgToJsonString(WxSendMusicMsg $msg)
    {
        $formatStr = '{
                        "touser":"%s",
                        "msgtype":"%s",
                        "music":
                        {
                          "title":"%s",
                          "description":"%s",
                          "musicurl":"%s",
                          "hqmusicurl":"%s",
                          "thumb_media_id":"%s"
                        }
                    }';
        $result = sprintf($formatStr,   $msg->getToUserName(),
                                        $msg->getMsgType(),
                                        $msg->getTitle(),
                                        $msg->getDescription(),
                                        $msg->getMusicUrl(),
                                        $msg->getHQMusicUrl(),
                                        $msg->getThumbMediaId()
                            );

        return $result;
    }
845409
def mavlink_to_json(msg):
    ''''''
    ret = '\"%s\": {' % msg._type
    for fieldname in msg._fieldnames:
        data = getattr(msg, fieldname)
        ret += '\"%s\" : \"%s\", ' % (fieldname, data)
    ret = ret[0:-2] + '}'
    return ret
240993
public function send($msg)
    {
        if (!$this->url) {
            return false;
        }
        $data = ["msgtype" => "text", "text" => ["content" => $msg], "at" => ["isAtAll" => true]];
        $curl = new LCurl(LCurl::POST_JSON, 3);
        $result = $curl->post(
            $this->url,
            $data
        );
        if (!$result || (int)Arrays::get($result, 'errcode') != 0) {
            return false;
        }
        return true;
    }
557932
public static String formatMessage(String msg, Object... params) {
		try {
			// required by MessageFormat, single quotes break string interpolation!
			msg = StringUtils.replace(msg, "'", "''");
			return StringUtils.isBlank(msg) ? "" : MessageFormat.format(msg, params);
		} catch (IllegalArgumentException e) {
			return msg;
		}
	}
736518
protected function _msg( $msg, $level = 0 )
	{
		$pre = '';
		for( $i = 0; $i < 2*$level; $i++ ) { $pre .= ' '; }

		echo str_pad( $pre . $msg, 70 );
	}
1371539
public function url($msg)
    {
        if(strlen(trim($this->_value)) > 0 && filter_var($this->_value, FILTER_VALIDATE_URL) === FALSE) {
            $this->_errors[] = $msg;
        }
        return $this;
    }
1220801
protected function formatExceptionMsg($exceptionMessage)
    {
        $exceptionMessage = str_replace("+++ Actual\n", '', $exceptionMessage);
        $exceptionMessage = str_replace("--- Expected\n", '', $exceptionMessage);
        $exceptionMessage = str_replace("@@ @@\n", '', $exceptionMessage);
        $exceptionMessage = preg_replace("/(Failed.*)$/m", " \033[01;31m$1\033[0m", $exceptionMessage);
        $exceptionMessage = preg_replace("/\-+(.*)$/m", "\n \033[01;32m$1\033[0m", $exceptionMessage);
        return preg_replace("/\++(.*)$/m", " \033[01;31m$1\033[0m", $exceptionMessage);
    }
115710
protected static function ctcpUnquote($msg)
    {
        // CTCP-level unquoting
        $quoting = array(
            "\\a"   => "\001",
            "\\\\"  => "\\",
            "\\"    => "",  // Ignore quoting character
                            // for invalid sequences.
        );
        $msg = strtr($msg, $quoting);

        // Low-level unquoting
        $quoting = array(
            "\0200"     => "\000",
            "\020n"     => "\n",
            "\020r"     => "\r",
            "\020\020"  => "\020",
            "\020"      => "",  // Ignore quoting character
                                // for invalid sequences.
        );
        $msg = strtr($msg, $quoting);
        return $msg;
    }
520343
protected function sendNewsMsgToXmlString(WxSendNewsMsg $msg)
    {
        $itemArray  = $msg->getAllArticleItems();
        $itemStr    = '';
        foreach ($itemArray as $item) {
            $itemStr .= $this->sendNewsItemToXmlString($item);
        }

        $formatStr = <<<XML
<xml>
<ToUserName><![CDATA[%s]]></ToUserName>
<FromUserName><![CDATA[%s]]></FromUserName>
<CreateTime>%d</CreateTime>
<MsgType><![CDATA[%s]]></MsgType>
<ArticleCount>%d</ArticleCount>
<Articles>
%s
</Articles>
</xml>
XML;

        $result = sprintf($formatStr,   $msg->getToUserName(),
                                        $msg->getFromUserName(),
                                        strtotime($msg->getCreateTime()),
                                        $msg->getMsgType(),
                                        $msg->getArticleCount(),
                                        $itemStr
                        );

        return $result;
    }
1343225
public function parseServerFirstMessage($msg)
    {
        $i = $r = $s = false;

        foreach (explode(',', $msg) as $val) {
            list($attr, $aval) = array_map('trim', explode('=', $val, 2));

            switch ($attr) {
            case 'i':
                $this->_iterations = intval($aval);
                $i = true;
                break;

            case 'r':
                /* Beginning of server-provided nonce MUST be the same as the
                 * nonce we provided. */
                if (strpos($aval, $this->_nonce) !== 0) {
                    return false;
                }
                $this->_nonce = $aval;
                $r = true;
                break;

            case 's':
                $this->_salt = base64_decode($aval);
                $s = true;
                break;
            }
        }

        if ($i && $r && $s) {
            $this->_authmsg .= ',' . $msg;
            return true;
        }

        return false;
    }
1125412
protected function getLocaleContext( array $msg )
	{
		$lcontext = clone $this->getContext();
		$manager = \Aimeos\MShop::create( $lcontext, 'locale' );

		$sitecode = ( isset( $msg['sitecode'] ) ? $msg['sitecode'] : 'default' );
		$localeItem = $manager->bootstrap( $sitecode, '', '', false, \Aimeos\MShop\Locale\Manager\Base::SITE_ONE );

		return $lcontext->setLocale( $localeItem );
	}
1171308
public static function error($msg)
    {
        $msg = 'Error: ' . $msg;
        $space = strlen($msg) + 4;
        $out  = static::colorize(str_pad(' ', $space), Color::FG_WHITE, Color::AT_BOLD, Color::BG_RED) . PHP_EOL;
        $out .= static::colorize('  ' . $msg . '  ', Color::FG_WHITE, Color::AT_BOLD, Color::BG_RED) . PHP_EOL;
        $out .= static::colorize(str_pad(' ', $space), Color::FG_WHITE, Color::AT_BOLD, Color::BG_RED) . PHP_EOL;

        return $out;
    }
942908
public function getAuthenticateFromChallenge(ChallengeMessage $msg)
    {
        $token = [
            'id' => $this->authid,
            'exp' => time() + 60,
        ];
        $token = JWT::encode($token, Security::salt());
        return new AuthenticateMessage($token);
    }
590826
public function Message($msg = '', $append = false)
    {
        if (is_null($msg)) {
            $this->_msg = array();
        } elseif (is_array($msg)) {
            if ($append) {
                $this->_msg = array_merge($this->_msg, $msg);
            } else {
                $this->_msg = $msg;
            }
            return $this->_msg;
        }
        return $this->_msg;
    }