1/*
2 * Copyright (C) 1984-2007 Mark Nudelman
3 *
4 * You may distribute under the terms of either the GNU General Public
5 * License or the Less License, as specified in the README file.
6 *
7 * For more information about less, or for information on how to
8 * contact the author, see the README file.
--- 553 unchanged lines hidden (view full) ---
562 public LWCHAR
563get_wchar(p)
564 char *p;
565{
566 switch (utf_len(p[0]))
567 {
568 case 1:
569 default:
570 return (LWCHAR)
571 (p[0] & 0xFF);
572 case 2:
573 return (LWCHAR) (
574 ((p[0] & 0x1F) << 6) |
575 (p[1] & 0x3F));
576 case 3:
577 return (LWCHAR) (
578 ((p[0] & 0x0F) << 12) |
579 ((p[1] & 0x3F) << 6) |
580 (p[2] & 0x3F));
581 case 4:
582 return (LWCHAR) (
583 ((p[0] & 0x07) << 18) |
584 ((p[1] & 0x3F) << 12) |
585 ((p[2] & 0x3F) << 6) |
586 (p[3] & 0x3F));
587 case 5:
588 return (LWCHAR) (
589 ((p[0] & 0x03) << 24) |
590 ((p[1] & 0x3F) << 18) |
591 ((p[2] & 0x3F) << 12) |
592 ((p[3] & 0x3F) << 6) |
593 (p[4] & 0x3F));
594 case 6:
595 return (LWCHAR) (
596 ((p[0] & 0x01) << 30) |
597 ((p[1] & 0x3F) << 24) |
598 ((p[2] & 0x3F) << 18) |
599 ((p[3] & 0x3F) << 12) |
600 ((p[4] & 0x3F) << 6) |
601 (p[5] & 0x3F));
602 }
603}
604
605/*
606 * Step forward or backward one character in a string.
607 */
608 public LWCHAR
609step_char(pp, dir, limit)
610 char **pp;
611 signed int dir;
612 char *limit;
613{
--- 496 unchanged lines hidden ---
2 * Copyright (C) 1984-2007 Mark Nudelman
3 *
4 * You may distribute under the terms of either the GNU General Public
5 * License or the Less License, as specified in the README file.
6 *
7 * For more information about less, or for information on how to
8 * contact the author, see the README file.
--- 553 unchanged lines hidden (view full) ---
562 public LWCHAR
563get_wchar(p)
564 char *p;
565{
566 switch (utf_len(p[0]))
567 {
568 case 1:
569 default:
570 return (LWCHAR)
571 (p[0] & 0xFF);
572 case 2:
573 return (LWCHAR) (
574 ((p[0] & 0x1F) << 6) |
575 (p[1] & 0x3F));
576 case 3:
577 return (LWCHAR) (
578 ((p[0] & 0x0F) << 12) |
579 ((p[1] & 0x3F) << 6) |
580 (p[2] & 0x3F));
581 case 4:
582 return (LWCHAR) (
583 ((p[0] & 0x07) << 18) |
584 ((p[1] & 0x3F) << 12) |
585 ((p[2] & 0x3F) << 6) |
586 (p[3] & 0x3F));
587 case 5:
588 return (LWCHAR) (
589 ((p[0] & 0x03) << 24) |
590 ((p[1] & 0x3F) << 18) |
591 ((p[2] & 0x3F) << 12) |
592 ((p[3] & 0x3F) << 6) |
593 (p[4] & 0x3F));
594 case 6:
595 return (LWCHAR) (
596 ((p[0] & 0x01) << 30) |
597 ((p[1] & 0x3F) << 24) |
598 ((p[2] & 0x3F) << 18) |
599 ((p[3] & 0x3F) << 12) |
600 ((p[4] & 0x3F) << 6) |
601 (p[5] & 0x3F));
602 }
603}
604
605/*
606 * Step forward or backward one character in a string.
607 */
608 public LWCHAR
609step_char(pp, dir, limit)
610 char **pp;
611 signed int dir;
612 char *limit;
613{
--- 496 unchanged lines hidden ---