[:punct:]?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[:punct:]?

Mikołaj Machowski
Hello,

What _exactly_ characters are covered by POSIX classes
[:punct:], [:print:], [:graph:]

Especially interested in punct.

TIA

m.
--
LaTeX + Vim = http://vim-latex.sourceforge.net/
Vim-list(s) Users Map: (last change 15 May)
 http://skawina.eu.org/mikolaj/vimlist
CLEWN - http://clewn.sf.net

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [:punct:]?

Paul-433
From 'man isalpha':

ispunct()
               checks for any printable character which is not a space or an
alphanumeric character.
isprint()
               checks for any printable character including space.
isgraph()
               checks for any printable character except space.

On Thu, 26 May 2005, Mikolaj Machowski wrote:

> Hello,
>
> What _exactly_ characters are covered by POSIX classes
> [:punct:], [:print:], [:graph:]
>
> Especially interested in punct.
>
> TIA
>
> m.
>

--

.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: punct:]?

David Fishburn
In reply to this post by Mikołaj Machowski
> What _exactly_ characters are covered by POSIX classes
> [:punct:], [:print:], [:graph:]
>
> Especially interested in punct.

Have a look at this Vim tip:

" Tip #499: View character class [[:alpha:]]
" http://vim.sourceforge.net/tips/tip.php?tip_id=499

I modified it slightly, so here is the version I use:


" This one shows the definition of a predefined character class. ([:alpha:],

" [:graph:] etc.) The cursor is assumed to point to the name of the
character
" class one wants to examine. Press "cc" ...
function! ShowCharacterClass( ... )
    if a:0 > 0
        " Optionally pass in the name of the character class
        let class = a:1
    else
        " Press cc while on the name of the character class
        let class = expand("<cword>")
    endif
    " Make this as forgiving as possible, strip off everything but
    " the character class name
    let class = matchstr(class, '\w\+')
    echo 'class [:' . class . ':]' . "\n"
    let pat = '[[:' . class . ':]]'
    let i = 0
    while i < 256
        let ch = nr2char(i)
        if ch =~ pat | echon ch . '(' . i . ')' . "\t" | endif
        let i = i + 1
    endwhile
endfunction

nnoremap cc :call ShowCharacterClass()<Cr>

HTH,
Dave

--
Do you use Vim to edit SQL?
<Plug>
Check the description of these plugins:
dbext.vim - Provides database access to 10 databases (Oracle, Sybase, SQL
Server, MySQL,...) (http://www.vim.org/scripts/script.php?script_id=356)
SQLUtilities - Formatting SQL, generate - columns lists, procedures for
databases (http://www.vim.org/scripts/script.php?script_id=492)
sql.vim - SQL indent file for Sybase ASA and Oracle
(http://www.vim.org/scripts/script.php?script_id=495)
Intellisense for Vim : SQL, C++, CSharp, Java, JSP, XML, HTML
(http://www.vim.org/scripts/script.php?script_id=747)
</Plug>


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: punct:]?

A. S. Budden
On 5/26/05, David Fishburn <[hidden email]> wrote:

> > What _exactly_ characters are covered by POSIX classes
> > [:punct:], [:print:], [:graph:]
> >
> > Especially interested in punct.
>
> Have a look at this Vim tip:
>
> " Tip #499: View character class [[:alpha:]]
> " http://vim.sourceforge.net/tips/tip.php?tip_id=499 
>
> I modified it slightly, so here is the version I use:
>
>
> " This one shows the definition of a predefined character class. ([:alpha:],
>
> " [:graph:] etc.) The cursor is assumed to point to the name of the
> character
> " class one wants to examine. Press "cc" ...
> function! ShowCharacterClass( ... )
>     if a:0 > 0
>         " Optionally pass in the name of the character class
>         let class = a:1
>     else
>         " Press cc while on the name of the character class
>         let class = expand("<cword>")
>     endif
>     " Make this as forgiving as possible, strip off everything but
>     " the character class name
>     let class = matchstr(class, '\w\+')
>     echo 'class [:' . class . ':]' . "\n"
>     let pat = '[[:' . class . ':]]'
>     let i = 0
>     while i < 256
>         let ch = nr2char(i)
>         if ch =~ pat | echon ch . '(' . i . ')' . "\t" | endif
>         let i = i + 1
>     endwhile
> endfunction
>
> nnoremap cc :call ShowCharacterClass()<Cr>

Just a thought, but does this need altering if you're working with
Unicode (and therefore there are a lot more than 256 characters...)?
Of course, it might then become a bit silly with what's displayed on
the screen, but if Mikolaj wants to know precisely what is covered,
then this may be an important situation.

Al
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: punct:]?

Mikołaj Machowski
Dnia czwartek 26 maj 2005 15:18, A. S. Budden napisa?:
>
> Just a thought, but does this need altering if you're working with
> Unicode (and therefore there are a lot more than 256 characters...)?
> Of course, it might then become a bit silly with what's displayed on
> the screen, but if Mikolaj wants to know precisely what is covered,
> then this may be an important situation.
>

Interesting. I have simplified David's idea to::

   let i = 0
   while i < 10000
       if nr2char(i) =~ '[[:punct:]]'
           put =nr2char(i)
       endif
       let i += 1
   endwhile

While in iso--8859-2 encoding (in Konsole) it works as ``i % 256`` (modulo)
up to 10000 and result has over 1800 lines, in gvim with utf-8 encoding it
shows only punctuation signs up to 256 *once* with 48 lines of output.

Looks like Vim is not catching some exotic punctuation character even if
ranges are defined in mbyte.c

m.
--
LaTeX + Vim = http://vim-latex.sourceforge.net/
Vim-list(s) Users Map: (last change 15 May)
 http://skawina.eu.org/mikolaj/vimlist
CLEWN - http://clewn.sf.net

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: punct:]?

A.J.Mechelynck
Mikolaj Machowski wrote:

> Dnia czwartek 26 maj 2005 15:18, A. S. Budden napisa?:
>
>>Just a thought, but does this need altering if you're working with
>>Unicode (and therefore there are a lot more than 256 characters...)?
>>Of course, it might then become a bit silly with what's displayed on
>>the screen, but if Mikolaj wants to know precisely what is covered,
>>then this may be an important situation.
>>
>
>
> Interesting. I have simplified David's idea to::
>
>    let i = 0
>    while i < 10000
>        if nr2char(i) =~ '[[:punct:]]'
>            put =nr2char(i)
>        endif
>        let i += 1
>    endwhile
>
> While in iso--8859-2 encoding (in Konsole) it works as ``i % 256`` (modulo)
> up to 10000 and result has over 1800 lines, in gvim with utf-8 encoding it
> shows only punctuation signs up to 256 *once* with 48 lines of output.
>
> Looks like Vim is not catching some exotic punctuation character even if
> ranges are defined in mbyte.c
>
> m.

See, below the definition of the classes (and just above ":help [==]"):
"These items work only for 8-bit characters".

If it doesn't catch any character >256, it's by design.


Best regards,
Tony.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: punct:]?

Mikołaj Machowski
Dnia czwartek 26 maj 2005 19:39, A. J. Mechelynck napisa?:

> > Interesting. I have simplified David's idea to::
> >
> >    let i = 0
> >    while i < 10000
> >        if nr2char(i) =~ '[[:punct:]]'
> >            put =nr2char(i)
> >        endif
> >        let i += 1
> >    endwhile
> >
> > While in iso--8859-2 encoding (in Konsole) it works as ``i % 256``
> > (modulo) up to 10000 and result has over 1800 lines, in gvim with
> > utf-8 encoding it shows only punctuation signs up to 256 *once* with
> > 48 lines of output.
>
> If it doesn't catch any character >256, it's by design.
>

Still, "modulo" behaviour is strange.

m.
Loading...