Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8326181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:41:09+00:00 2026-06-09T00:41:09+00:00

I am trying to read emails through Exchange Server 2003 through a URL in

  • 0

I am trying to read emails through Exchange Server 2003 through a URL in PHP. Files that have characters not allowed in filenames convert them into some form of Unicode. For e.g / is converted to xF8FF and \ is converted to xF8FE

How can I use PHP to convert these characters into the correct encoding? I know I could take a long way around and use str_replace, but I know that other characters such as : ; * < > will have the same problem. Does PHP support this encoding natively?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T00:41:10+00:00Added an answer on June 9, 2026 at 12:41 am

    Starting from the source code of the Ximian Connector for Microsoft Exchange (written in the C programming language), I’ve made up this sample of PHP code:

    <?php
    
    class myExchange {
        private $uri_encoded_char = array(
            1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 0x00 - 0x0f */
            1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 0x10 - 0x1f */
            1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 2,  /*  ' ' - '/'  */
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 2,  /*  '0' - '?'  */
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  /*  '@' - 'O'  */
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 1, 1, 0,  /*  'P' - '_'  */
            1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  /*  '`' - 'o'  */
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 1,  /*  'p' - 0x7f */
            1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
            1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
            1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
            1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
            1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
            1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
            1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
            1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
        );
    
        /**
         * e2k_uri_append_encoded: 
         *  
         * Appends $in to $str, encoding URI-unsafe characters as needed
         * (optionally including some Exchange-specific encodings).
         * When appending a path, you must append each segment separately;
         * e2k_uri_append_encoded() will encode any "/"s passed in.
         *  
         * @param string $str               a string containing part of a URI
         * @param string $in                data to append to $str
         * @param bool   $wss_encode        whether or not to use the 
         *                                  special Web Storage System
         *                                  encoding rules
         * @param string $extra_enc_chars   additional characters beyond 
         *                                  the normal URI-reserved
         *                                  characters to encode when
         *                                  appending to $str
         * @return string  
         **/
        public function e2k_uri_append_encoded($str, $in, $wss_encode, $extra_enc_chars) {
            $len = strlen($in);
            for ($i = 0; $i < $len; $i++) {
                $s = $in[$i];
                $c = ord($s);
                if ($extra_enc_chars && strchr($extra_enc_chars, $s)) {
                    $str .= sprintf("%%%02x", $c);
                } else {
                    switch ($this->uri_encoded_char[$c]) {
                        case 2:
                            if (!$wss_encode) {
                                $str .= sprintf("%%%02x", $c);
                            } else {
                                switch ($s) {
                                    case '/':
                                        $str .= "_xF8FF_";
                                        break;
                                    case '?':
                                        $str .= "_x003F_";
                                        break;
                                    case '\\':
                                        $str .= "_xF8FE_";
                                        break;
                                    case '~':
                                        $str .= "_x007E_";
                                        break;
                                }
                            }
                            break;
                        case 1:
                            $str .= sprintf("%%%02x", $c);
                            break;
                        default:
                            $str .= $s;
                            break;
                    }
                }
            }
            return($str);
        }
    }
    
    $filename = "@#£¤$%&/{([)]=}+?'`|~,;.:-_<>æøåäâãëêïîöôõüûÿ\\.EML";
    
    $e = new myExchange();
    echo $e->e2k_uri_append_encoded("", $filename, true, null);
    echo "\n";
    
    ?>
    

    Here is the output:

    @%23%a3%a4$%25%26_xF8FF_%7b(%5b)%5d=%7d+_x003F_'%60%7c_x007E_,;.:-_%3c%3e%e6%f8%e5%e4%e2%e3%eb%ea%ef%ee%f6%f4%f5%fc%fb%ff_xF8FE_.EML
    

    Unfortunately I don’t have an Exchange Server, so I can’t tell if it really works, however I hope it can be a good starting point.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to access an exchange server to read emails from a specific
After trying to read various articles on sending emails with attachments in PHP (I
I am trying to read in an XML file that I have saved to
I have an id that i am trying to read from my database and
I'm trying to read through a gmail account to get gps data that is
I'm trying to create a system in PHP/Zend that can gather emails from various
I am trying to read Contact names, phone #'s, and emails from the ContactsContract
I'm trying to build a small webmail app. When I read all the emails
I am trying to read through an email inbox for my application - I'm
I am trying to read my emails using a Python script (Python 2.5 and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.