PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.ruby > Detect non-ascii substrings in a file
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Detect non-ascii substrings in a file

Réponse
 
LinkBack Outils de la discussion
Vieux 19/06/2008, 03h41   #1
killy971
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Detect non-ascii substrings in a file

I have files encoded in Shift_JIS, that mainly contains JSP source
code (ascii), but sometimes also contains strings that are non-ascii
(japanese words).

So, I would like to know if there is a way with ruby to :
- detect files containing something else than ascii,
- extract the non-ascii strings thare were found.

Thank you !
  Réponse avec citation
Vieux 19/06/2008, 11h34   #2
Ron Fox
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Detect non-ascii substrings in a file

Any character that has the top bit clear is potentially valid ascii,
though if you take away the non printing characters there's an
additional exlusion set.
According to http://en.wikipedia.org/wiki/Shift-JIS

Testing for character codes with the top bit set should indicate
either katakana or double byte characters. See the chart there for
which ranges are double byte, which are single and which are not legal.

RF

killy971 wrote:
> I have files encoded in Shift_JIS, that mainly contains JSP source
> code (ascii), but sometimes also contains strings that are non-ascii
> (japanese words).
>
> So, I would like to know if there is a way with ruby to :
> - detect files containing something else than ascii,
> - extract the non-ascii strings thare were found.
>
> Thank you !



--
Ron Fox
NSCL
Michigan State University
East Lansing, MI 48824-1321
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 03h08.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,10647 seconds with 10 queries