How can I input UTF-8 CJK character in .sty file

I compile my tex file with xelatex

and I want to renew the \lstlistlistingname

In this case, I just use \renewcommand to do this job.

It success if I put this command after package in tex file

but how can I move this command to .sty file.

Notice, The new lstlistlistingname is some CJK character and the file encoding with UTF-8

-
? Where is your problem. If it is a personal style you can use utf8 chars if you want. –  Ulrike Fischer Jun 21 '12 at 17:46
Do you input CJK enconding first and then redefine lstlistlistingname? –  robert.marik.cz Jun 21 '12 at 19:07
Which .sty file do you put it in? Please provide a miniaml working example. –  Leo Liu Jun 22 '12 at 10:04

This example works for me:

The package:

% encoding: UTF-8
% ccode.sty
\ProvidesPackage{ccode}[2012/06/22 test listings]
\RequirePackage{xeCJK}
\setCJKmainfont{SimSun}
\RequirePackage{listings}
\renewcommand\lstlistingname{代码}
\lstnewenvironment{ccode}[2][]{\lstset{language=C,caption=#2,#1}}{}
\endinput


The test document:

% encoding: UTF-8
% foo.tex
\documentclass{article}
\usepackage{ccode}
\begin{document}
\begin{ccode}{测试}
#include <stdio.h>
int main()
{
puts("Hello world.");
return 0;
}
\end{ccode}
\end{document}

-