Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: ASCII to UTF-8 or Spectrum to Blue.

by frankus (Priest)
on Jul 26, 2002 at 14:45 UTC ( #185552=note: print w/replies, xml ) Need Help??

in reply to ASCII to UTF-8

This is for Welsh language, it's a cool language.
Not sure why the problem is occuring but...
I'm rewriting the code to be a bit more concise, then I might be able to:
  1. see what it does
  2. understand your request ;)

use strict ; use CGI qw/:standard/; use CGI::Carp qw(fatalsToBrowser); use HTML::Template; use Data::Dumper; use Unicode::String; use lemma; my $q = new CGI; my $template = "bbc/lemma/wsillafu.tmpl"; my $tmpl = new HTML::Template( filename =>$template,associate => $q ); + # Consider using an array to make getting and setting easier. # You could then use array slices to set them ;) my $errorchecker = 0; my $memoryoverloadchecker = 0; my $memorychecker = 0; my $dictionarychecker = 0; my $otherchecker = 0; my $memoryfinder = 0; print $q->header(); if ($q->param()) { my ( $spellingcheck, $error) = lookup($q->param("brawddeg")); # Is t +his pronounced brahtheg? $tmpl->param( spellingcheck => $spellingcheck ); ($errorchecker,$memoryfinder) = (1,1) if $error == 1; ($memoryoverloadchecker,$memoryfinder) = (1,1) if $error == -1; ($memorychecker, $memoryfinder) = (1,1) if $error == -2; ($dictionarychecker, $memoryfinder) = (1,1) if $error == -3; ($otherchecker,$memoryfinder) = (1,1) if $error == -4; } print $tmpl->output; if( $dictionarychecker ) { print "<br><br>Nid yw\'r geiriadur ar-lein ar gael. E-bostiwch meis +tr y wefan am gymorth \n"; } if( $otherchecker ){ print "<br><br>Mae gwall yn y gwirydd. E-bostwich meistr y wefan a +m gymorth \n"; } if( $memoryoverloadchecker ){ print "<br><br>Roedd mwy na 10 gwall yn y testun. Dim ond y 10 gwa +ll cyntaf sydd wedi ei cywiro.<br> Cywirwch rhain cyn cario ymlaen i gywiro.\n"; } if( $memorychecker ) { print "<br><br>Mae'r gwirydd wedi rhedeg allan o gof. E-bostiwch m +eistr y wefan am gymorth.\n"; } if( $errorchecker ) { print "<br><br><font color=\"red\"><b>Mae rhai gwallau yng nghorff +y testun.</b></font><br> Dewiswch air gynhigir yn y blwch tynnu i lawr i bob gair sy +dd wedi ei sillafu'n anghywir. <br>Yna gwagswch y botwm gwirio isod i gael eich testun wedi +ei wirio.<br>\n"; print "<form name=\"ArgraffyddTestun\" method=\"POST\" Action=\"wsi\">\n"; print "<input type=\"Submit\" name=\"Gwirio\" value=\"Gwirio\"></fo +rm>\n"; } unless( $memoryfinder ) { print "<br><br><b>Nid oedd gwall yn y frawddeg</b>\n"; } sub lookup { # Don't think you want a prototype as you had it ;) $_ = shift; # the @_ is redundant, it's implicit. my ($errors, $str) = lemma::GetCysillSpellingErrors($_, 10); my @fields = split ("(<awgrymiadau>[^<]*</awgrymiadau>)", $str); my $error = @fields > 1; my @spellingcheck = (); return (\@spellingcheck, 'odd amount of values') unless @fields % +2; # Remove the last two items my $last_field = pop(@fields); pop(@fields); my ($key,$value); while ( ($key,$value,@fields) = @fields ) { $value =~ s/<[^>]*>//g; my @SuggestionList = split /,/, $value; # Consider Text::CS +V here ;) # Saves a bit of space. my @suggestions = map{suggestion=> $_}@SuggestionList; # Create an anonymous hash push @spellingcheck, {text=> $key, thesuggestions=>\@suggestion +s}; } return ([ @spellingcheck,{text=> $last_field} ], $errors) ; }
This should do the same things, with a bit more clarity

However I can't see anything here that refers to Latin or UTF-8.. where is that glitch occuring?


Brother Frankus.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://185552]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2017-07-29 12:36 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (436 votes). Check out past polls.