PHP Chinese word source encountered a small problem

Source: Internet
Author: User
Define (' _sp_ ', Chr (0xFF). Chr (0xFE)); Define (' UCS2 ', ' ucs-2be ');

What is the purpose of these 2 constants definitions? _SP_ is defined as Chr (0xFF). chr (0xFE) What do you mean, I can not find in the ASCII table FF,FE these 2 corresponding coding ah?
The following code is
        Loading sub-dictionary        $hw = ';        $ds = file ($dicAddon); txt format dictionary file for//17 line        foreach ($ds as $d)        {            $d = trim ($d);            if ($d = = ") Continue;            $estr = substr ($d, 1, 1);            if ($estr = = ': ') {                $HW = substr ($d, 0, 1);            }            else            {                $spstr = _sp_;                $spstr = Iconv (UCS2, ' utf-8 ', $spstr);//How does UCS2 code appear? What                's the $WS = Explode (', ', $d);//each line of kanji, separated by an intermediate comma into an array                $wall = Iconv (' Utf-8 ', UCS2, join ($SPSTR, $WS));//With _SP_ and combine them into strings?? , and then converted it into a ucs2?                $ws = Explode (_sp_, $wall);//And then split into groups? What do you mean AH!!!                foreach ($ws as $estr)                {                    $this->addondic[$HW] [$estr] = strlen ($ESTR);}}}        


This code is loading the dictionary file, but I don't understand the logic of the Else code? Who can talk about it briefly?


Reply to discussion (solution)

Your dictionary file is UCS-2BE encoded.

Chr (0xFF). Chr (0xFE) is Ucs-2be's BOM

Your dictionary file is UCS-2BE encoded.

Chr (0xFF). Chr (0xFE) is Ucs-2be's BOM

Still some do not understand, the establishment _sp_ this constant has what function? Ucs-2be's BOM is written directly into a variable on the line, why also take the Chr () function to calculate it?

Chr (0xFF). chr (0xFE) can write "\xff\xfe"
But the author is not as smart as you, so I wrote it with a string function.

Chr (0xFF). chr (0xFE) can write "\xff\xfe"
But the author is not as smart as you, so I wrote it with a string function.
The author is the author of Dede, how is it possible? Kending Bushi Zheyangde

It's not him, it's you.
I don't know how to work!

It's not him, it's you.
I don't know how to work!
Moderator, I really do not understand, others use _SP_ when the string segmentation logo, not BOM bar, can help!

A BOM is an encoding type declaration that interprets _sp_ as a BOM to help understand
You are not "in the ASCII table can not find ff,fe these 2 corresponding code"
Look again

Define (' _sp_ ', Chr (0xFF). Chr (0xFE)); Define (' UCS2 ', ' ucs-2be '); $spstr = _sp_; $spstr = Iconv (UCS2, ' utf-8 ', $spstr); Echo Bin2Hex ($SPSTR);
Get Efbfbe
This is Utf-8 's BOM.

As to why he did it, look at the dictionary file and you'll know what's going on.

A BOM is an encoding type declaration that interprets _sp_ as a BOM to help understand
You are not "in the ASCII table can not find ff,fe these 2 corresponding code"
Look again

Define (' _sp_ ', Chr (0xFF). Chr (0xFE)); Define (' UCS2 ', ' ucs-2be '); $spstr = _sp_; $spstr = Iconv (UCS2, ' utf-8 ', $spstr); Echo Bin2Hex ($SPSTR);
Get Efbfbe
This is Utf-8 's BOM.

As to why he did it, look at the dictionary file and you'll know what's going on.
You don't seem right, but no one knows that.
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.