Language Library - ENCODING ERROR(SOLVED)

#1
[eluser]Shiro[/eluser]
Dear all,

I just want to ask is it possible load two language files into one controller?

what I face the problem is when I load another language file, my html will added another "invisible" character, not sure is "nextline" or "space", when I paste to ANSI encoding text, it show ? beside <html>.


This is the test I run with CI 1.7.2, and with WAMP

I downloaded the CI framework unpacked it,
CASE 1:

in the default controller (welcome.php) I added
Code:
function index()
    {
        $this->lang->load('error', 'english');
        //$this->lang->load('test', 'english');
        
        $this->load->view('welcome_message');
    }

the view file
Code:
<body>
<?php echo $this->lang->line('test');?>
<h1>Welcome to CodeIgniter!</h1>

in the file system, /language , I create these two file
error_lang.php and test.php, these two files are having same content which is

Code:
&lt;?php
$lang['test'] = "test";

When I load the controller, the page is ok, load perfectly. Because it just load one language file.

But when I uncomment another language file, there got an extra character come out.
CASE 2:

in the default controller (welcome.php) I added
Code:
function index()
    {
        $this->lang->load('error', 'english');
        $this->lang->load('test', 'english');
        
        $this->load->view('welcome_message');
    }

So, I just want to ask is it possible load two language files into one controller? or this is CI bug?

Edit:
The reason I ask is because I got another CI project, when I load 2 language files, the top part of the header will go down a next line. but if I load 1 language file, no problem for it.

#2
[eluser]Shiro[/eluser]
after I did some research, I think problem is related something with

 - BOM characters

anyone got any idea?

#3
[eluser]Shiro[/eluser]
**solve!!!**

I fault.... actually is the text file encoding problem,
I use notepad++, set the encoding to UTF-8 without BOM then my problem solve..

Happy New Year!!!!

Edit:

Today start to read the user guide, i found that
Quote:File Format

Files should be saved with Unicode (UTF-8) encoding. The BOM should not be used. Unlike UTF-16 and UTF-32, there's no byte order to indicate in a UTF-8 encoded file, and the BOM can have a negative side effect in PHP of sending output, preventing the application from being able to set its own headers. Unix line endings should be used (LF).

Here is how to apply these settings in some of the more common text editors. Instructions for your text editor may vary; check your text editor's documentation.
TextMate

1. Open the Application Preferences
2. Click Advanced, and then the "Saving" tab
3. In "File Encoding", select "UTF-8 (recommended)"
4. In "Line Endings", select "LF (recommended)"
5. Optional: Check "Use for existing files as well" if you wish to modify the line endings of files you open to your new preference.

BBEdit

1. Open the Application Preferences
2. Select "Text Encodings" on the left.
3. In "Default text encoding for new documents", select "Unicode (UTF-8, no BOM)"
4. Optional: In "If file's encoding can't be guessed, use", select "Unicode (UTF-8, no BOM)"
5. Select "Text Files" on the left.
6. In "Default line breaks", select "Mac OS X and Unix (LF)"


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.