Re: utf8 issues in Scintilla(again)
| From: | Fernando Correa da Conceição | Date: | Tue, 04 Jul 2006 04:08:03 +0000 |
| Subject: | Re: utf8 issues in Scintilla(again) | ||
| References: | 1 2 | Groups: | php.gtk.dev |
| Request: | Send a blank email to php-gtk-dev+get-3186@lists.php.net to get a copy of this message | ||
Em Seg 03 Jul 2006 06:42, Anant Narayanan escreveu:
> Hi Fernando,
>
> > But that path generates a new error.
>
> It would be helpful to know what the new error is. I ran a test before I
> committed the override, and it all seemed to work fine on my box, with
> the accented e's and everything.
>
> > Please commit this to scintilla.overrides
>
> I don't quite see how the patch would solve the "error" you're getting.
> Until some higher authority (Christian, Steph, Andrei?) looks at this
> issue, I maintain that my earlier commit (which converts the text from
> UTF8 and then passed it to set_text) is the correct thing to do. Your
> patch, BTW, doesn't work for me.
>
> Meanwhile, passing us the errors you are getting along with the script
> you are using to generate them, would go a long way in helping us solve
> the issue.
>
> > I will work now in the other functions, as this may happen in all
> > functions from scintilla which accept a string as argumment.
>
> Please do that, it's more than welcome :). But, I would suggest you to
> take a more cautious approach and wait for a consensus on the first
> patch, so that there is no wasted/duplicate effort.
>
Since I do not explain myself in previous email, sorry :(
So, this is the part of my code:
if ($continue == "") {
if (file_exists($filename) && is_readable($filename)) {
$text = file_get_contents($filename);
$this->editor->set_text($text);
} else {
where $this->editor is a GtkScintilla object.
The error is this:
Fatal error: Uncaught exception 'PhpGtkGErrorException' with
message 'Sequência de bytes
inválida na entrada de conversão' in /home/comum/TextEditor/classes/
ScintillaEditor.php:38
Stack trace:
#0 /home/comum/TextEditor/classes/ScintillaEditor.php(38):
GtkScintilla->set_tex
t('<?php?/**? * Th...')
#1 /home/comum/TextEditor/classes/TextEditor.php(88):
ScintillaEditor->load('/ho
me/comum/Tex...')
#2 /home/comum/TextEditor/classes/TextEditor.php(124):
TextEditor->newTab('/home /comum/Tex...')
#3 [internal function]: TextEditor->onMenuOpen()
#4 /home/comum/TextEditor/TextEditor.php(51): Gtk::main()
#5 {main}
thrown in /home/comum/TextEditor/classes/ScintillaEditor.php on line 38
The error message is in Brazilian Portuguese. What it tell is that there is a
byte sequence invalid in the input chars for the conversion. so look at this:
# is my comment
PHP_METHOD
{
char *utf8; #dont need
gchar *text;
zend_bool free_utf8 = FALSE; #dont need
zend_bool free_text = FALSE;
gsize len = 0;
NOT_STATIC_METHOD();
if (!php_gtk_parse_args(ZEND_NUM_ARGS(), "s", &utf8, &free_utf8))
return;
text = phpg_from_utf8(utf8, strlen(utf8), &len, &free_text TSRMLS_CC);
#the above line is wrong! the utf8 var here comes from a php variable, so
it is not encoded in utf8, but it is a plain string. We need this for values
that comes from gtk, not the ones that comes from php, so since it is not
encoded in utf8 it contains character like áã which is invalid for a utf8
encoded string, so it generates a fatal exception.
# the fix is simple: do not make this!
if (text && free_text) {
gtk_scintilla_set_text(GTK_SCINTILLA(PHPG_GOBJECT(this_ptr)), text);
g_free(text);
}
if (free_utf8)
g_free(utf8);
}
> Thanks for everything!
>
> Best Regards,
>
> - Anant
_______________________________________________________
Yahoo! Acesso Grátis - Internet rápida e grátis. Instale
o discador agora!
http://br.acesso.yahoo.com