douxian3828 2019-06-12 02:33
浏览 102
已采纳

PHP:在RTF中使用str_replace替换不一致

I'm using PHP and the str_replace function to replace (in this case remove) some code from within an RTF file. It replaces some blocks of code in the RTF file fine, but others do not replace and I cant tell why.

I'm trying to use this function to remove paragraphs from an RTF file:

$document = str_replace('CODE-TO-REMOVE-GOES-HERE', '', $document);

This code works fine:

$document = str_replace('\par }\pard\plain \ltrpar\qc \li0i0\sl480\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustrightin0\lin0\itap0\pararsid5841714 tlch\fcs1 \af0\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {
tlch\fcs1 \ab\af0\afs24 \ltrch\fcs0 \b\f0\fs24\insrsid5841714\charrsid5841714 BOLDED CENTERED HEADING}{tlch\fcs1 \ab\af0\afs24 \ltrch\fcs0 \b\f0\fs24\insrsid5841714 ', '', $document);

but for some reason this section does not:

$document = str_replace('\par {\listtext\pard\plain\ltrpar \s15 tlch\fcs1 \af0 \ltrch\fcs0 \insrsid5841714 \hich\af0\dbch\af0\loch\f0 5.\tab}}\pard\plain \ltrpar\s15\ql \fi720\li0i0\sl480\slmult1
\widctlpar\wrapdefault\aspalpha\aspnum\faauto\ls2\adjustrightin0\lin0\itap0\pararsid3021950\contextualspace tlch\fcs1 \af0\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {tlch\fcs1 \af0\afs24 \ltrch\fcs0 
\f0\fs24\insrsid5841714 This text in the paragraph open(s) non-broken put(s) this is additional sample text that will not remove (CPL \'a7\'a7
 100.00[1][x]; 100.23[3])', '', $document);

The first block of code (removing the BOLDED CENTERED HEADING) works fine and removes that line RTF, but the second block, which is trying to remove the paragraph directly below the BOLDED CENTERED HEADING, doesn't remove or seem to do anything.

Can anyone spot the difference between these two that is causing one to replace but not the other?

Edit/Update: all the files (rtf, html, php) are encoded in UTF-8 (according to Notepad++). php.ini has default_charset = "UTF-8" and .htaccess has AddDefaultCharset UTF-8

Here is the entire PHP file at this point. It's only a test to see if this was possible. It takes inputs from a form and inserts them into the RTF, but also tries to remove some paragraphs - which is the part I'm failing at. I'm starting to think it has something to do with the parentheses.

<?php


header('Content-Type: text/html; charset=UTF-8');

mb_internal_encoding('UTF-8'); 
mb_http_output('UTF-8'); 
mb_http_input('UTF-8'); 
mb_regex_encoding('UTF-8'); 



if (isset($_POST['prp'])){


$document = file_get_contents("city-omnibus-template.rtf");

$defendantphp = $_POST['defendanthtml'];
$judgephp = $_POST['judgehtml'];
$crnumphp = $_POST['crnumhtml'];
$adaphp = $_POST['adahtml'];
$attyphp = $_POST['attyhtml'];
$motargdatephp = $_POST['motargdatehtml'];
$deftodisphp = $_POST['deftodishtml'];
$crimedatephp = $_POST['crimedatehtml'];
$motsigndatephp = $_POST['motsigndatehtml'];
$accusdatephp = $_POST['accusdatehtml'];
$allcrimeschargedphp = $_POST['allcrimeschargedhtml'];

if (empty($fax)){
$fax='-';
    }

$document = str_replace("#defendantword", $defendantphp, $document);
$document = str_replace("#judgeword", $judgephp, $document);
$document = str_replace("#crnumword", $crnumphp, $document);
$document = str_replace("#adaword", $adaphp, $document);
$document = str_replace("#attyword", $attyphp, $document);
$document = str_replace("#motargdateword", $motargdatephp, $document);
$document = str_replace("#deftodisword", $deftodisphp, $document);
$document = str_replace("#crimedateword", $crimedatephp, $document);
$document = str_replace("#motargdateword", $motsigndatephp, $document);
$document = str_replace("#accusdateword", $accusdatephp, $document);
$document = str_replace("#allcrimeschargedword", $allcrimeschargedphp, $document);


// this one works
$document = str_replace('\par }\pard\plain \ltrpar\qc \li0i0\sl480\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustrightin0\lin0\itap0\pararsid5841714 tlch\fcs1 \af0\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {
tlch\fcs1 \ab\af0\afs24 \ltrch\fcs0 \b\f0\fs24\insrsid5841714\charrsid5841714 PROSECUTION BY INFORMATION}{tlch\fcs1 \ab\af0\afs24 \ltrch\fcs0 \b\f0\fs24\insrsid5841714 ', '', $document);

//this one does not
$document = str_replace('\par {\listtext\pard\plain\ltrpar \s15 tlch\fcs1 \af0 \ltrch\fcs0 \insrsid5841714 \hich\af0\dbch\af0\loch\f0 5.\tab}}\pard\plain \ltrpar\s15\ql \fi720\li0i0\sl480\slmult1
\widctlpar\wrapdefault\aspalpha\aspnum\faauto\ls2\adjustrightin0\lin0\itap0\pararsid3021950\contextualspace tlch\fcs1 \af0\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {tlch\fcs1 \af0\afs24 \ltrch\fcs0 
\f0\fs24\insrsid5841714 The defendant has entered a plea of not guilty to the charge(s) alleged in the accusatory instrument. To the extent that any of 
the pending non-felony charge(s) are based upon a hearsay complaint, rather than a non-hearsay information, the defendant hereby refuses to consent to be prosecuted by such complaint and demands to be prosecuted by a non-hearsay information (CPL \'a7\'a7
 170.10[4][d]; 170.65[1])', '', $document);


header("Content-type: application/msword");
header("Content-disposition: inline; filename=$defendantphp-Omnibus.doc");
header("Content-length: ".strlen($document));
echo iconv('UTF-8', 'ISO-8859-1', $document);

}
?>

Link to RTF file: https://drive.google.com/open?id=11sH7RnpuQ1YJq8GFnhclN8kxxBB_SIlo

More edits:

Workaround - this is probably a terrible way of doing it, but it seems like it works if I remove the parentheses ( ) and section symbol § (replacing it in the RTF with some stand in code like ##118##) - and then doing another str_replace to change the (unremoved) stand in code back to a parentheses or section symbol. But if there's a better way I'm still looking for it.

Significant Progress Made - one part still not working Everything is working except for this last section which won't replace. The only thing I can tell is any different about it is that it has a nested list, but I don't know why that would matter.

Here's the chunk that won't replace:

$search3 = <<<'EOL'
\par }\pard\plain \ltrpar\qc \li0i0\sl480\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustrightin0\lin0\itap0\pararsid5841714 tlch\fcs1 \af0\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {
tlch\fcs1 \ab\af0\afs24 \ltrch\fcs0 \b\f0\fs24\insrsid5841714\charrsid5841714 DEFECTIVE INFORMATION}{tlch\fcs1 \ab\af0\afs24 \ltrch\fcs0 \b\f0\fs24\insrsid5841714 
\par {\listtext\pard\plain\ltrpar \s15 tlch\fcs1 \af0 \ltrch\fcs0 \insrsid5841714 \hich\af0\dbch\af0\loch\f0 6.\tab}}\pard\plain \ltrpar\s15\ql \fi720\li0i0\sl480\slmult1
\widctlpar\wrapdefault\aspalpha\aspnum\faauto\ls2\adjustrightin0\lin0\itap0\pararsid3021950\contextualspace tlch\fcs1 \af0\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {tlch\fcs1 \af0\afs24 \ltrch\fcs0 
\f0\fs24\insrsid5841714 The defendant hereby moves, pursuant to CPL }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid5841714  170.30}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 
\f0\fs24\insrsid3021950 , to dismiss the accusatory or count charging the offense}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid3021950 s}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 
\f0\fs24\insrsid14111911 )}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid3021950  of }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 #deftodisword on the ground that it is defective. An accusatory instrument }{tlch\fcs1 \af0\afs24 
\ltrch\fcs0 \f0\fs24\insrsid14111911 (}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 or count thereof}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 
 is defective if it is not sufficient on itquote s face pursuant to the requirements of CPL }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306  100.40 }{tlch\fcs1 \af0\afs24 
\ltrch\fcs0 \f0\fs24\insrsid14111911 (}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 CPL }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306  170.35[1][a]}{
tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 ;}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid5841714 
\par {\listtext\pard\plain\ltrpar \s15 tlch\fcs1 \af0 \ltrch\fcs0 \insrsid13307306 \hich\af0\dbch\af0\loch\f0 7.\tab}}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 
To be sufficient on its face, a local criminal court accusatory which purports to qualify as an \'93information\'94 must satisfy the requirements set forth below:
\par {\listtext\pard\plain\ltrpar \s15 tlch\fcs1 \af0 \ltrch\fcs0 \insrsid13307306 \hich\af0\dbch\af0\loch\f0 a.\tab}}\pard \ltrpar
\s15\ql \fi-360\li1440i0\widctlpar\wrapdefault\aspalpha\aspnum\faauto\ls2\ilvl1\adjustrightin0\lin1440\itap0\pararsid13446461\contextualspace {tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 An information \'93
must contain an accusatory part and a factual part. The complainantquote s verification of the instrument is deemed to apply only to the }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 factual part thereof and not to the accusatory part.
\'94 }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 CPL }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 
\f0\fs24\insrsid13446461  100.15[1]}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 ;\line }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 
\par {\listtext\pard\plain\ltrpar \s15 tlch\fcs1 \af0 \ltrch\fcs0 \insrsid13446461 \hich\af0\dbch\af0\loch\f0 b.\tab}}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 The accusatory part \'93must designate the offense or offenses charged\'94 }{
tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 CPL }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 
 100.15[2]}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 ;\line 
\par {\listtext\pard\plain\ltrpar \s15 tlch\fcs1 \af0 \ltrch\fcs0 \insrsid13446461 \hich\af0\dbch\af0\loch\f0 c.\tab}The factual part \'93
must contain a statement of the complainant alleging facts of an evidentiary character supporting or tending to support the charges\'94 }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 
\f0\fs24\insrsid13446461 CPL }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461  100.15[3]; see also }{tlch\fcs1 \ai\af0\afs24 \ltrch\fcs0 
\i\f0\fs24\insrsid13446461\charrsid13446461 People v. Dumas}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 , 68 NY2d [1986]}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 
\f0\fs24\insrsid13446461 ;\line 
\par {\listtext\pard\plain\ltrpar \s15 tlch\fcs1 \af0 \ltrch\fcs0 \insrsid13446461 \hich\af0\dbch\af0\loch\f0 d.\tab}The allegations of the factual part, together with those of any supporting depositions which may accompany it, must \'93
provide reasonable cause to believe that the defendant committed the offense charged in the accusatory part of the information\'94 }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 
\f0\fs24\insrsid13446461 CPL }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461  100.40[1][b]}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{tlch\fcs1 
\af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 ;\line 
\par {\listtext\pard\plain\ltrpar \s15 tlch\fcs1 \af0 \ltrch\fcs0 \insrsid13446461 \hich\af0\dbch\af0\loch\f0 e.\tab}Finally, every element of the offense charged and the defendantquote s commission thereof must be established by \'93
non-hearsay allegations of the factual part of the information and/or of any supporting depositions\'94 }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 CPL }{tlch\fcs1 
\af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461  100.40[1][c]; }{tlch\fcs1 \ai\af0\afs24 \ltrch\fcs0 \i\f0\fs24\insrsid13446461\charrsid13446461 see also People v. Alejandro}{tlch\fcs1 
\af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 , 70 NY2d 133 [1987]}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 .
\par }\pard\plain \ltrpar\ql \li0i0\sl480\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustrightin0\lin0\itap0\pararsid13446461 tlch\fcs1 \af0\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {
tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 
EOL;
$document = str_replace($search3, '', $document);

And here's the updated version of the PHP with fyrye's fixes included:

<?php

header('Content-Type: text/html; charset=UTF-8');


if (isset($_POST['prp'])){


$document = file_get_contents("city-omnibus-template.rtf");

// not sure what this does - changes all line endings?
$document = str_replace(["
", "
"], ["
", "
"], $document);


$defendantphp = $_POST['defendanthtml'];
$judgephp = $_POST['judgehtml'];
$crnumphp = $_POST['crnumhtml'];
$adaphp = $_POST['adahtml'];
$attyphp = $_POST['attyhtml'];
$motargdatephp = $_POST['motargdatehtml'];
$deftodisphp = $_POST['deftodishtml'];
$crimedatephp = $_POST['crimedatehtml'];
$motsigndatephp = $_POST['motsigndatehtml'];
$accusdatephp = $_POST['accusdatehtml'];
$allcrimeschargedphp = $_POST['allcrimeschargedhtml'];

if (empty($fax)){
$fax='-';
    }

$document = str_replace("#defendantword", $defendantphp, $document);
$document = str_replace("#judgeword", $judgephp, $document);
$document = str_replace("#crnumword", $crnumphp, $document);
$document = str_replace("#adaword", $adaphp, $document);
$document = str_replace("#attyword", $attyphp, $document);
$document = str_replace("#motargdateword", $motargdatephp, $document);
$document = str_replace("#deftodisword", $deftodisphp, $document);
$document = str_replace("#crimedateword", $crimedatephp, $document);
$document = str_replace("#motargdateword", $motsigndatephp, $document);
$document = str_replace("#accusdateword", $accusdatephp, $document);
$document = str_replace("#allcrimeschargedword", $allcrimeschargedphp, $document);


// this one is working now
$search1 = <<<'EOL'
\par }\pard\plain \ltrpar\qc \li0i0\sl480\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustrightin0\lin0\itap0\pararsid5841714 tlch\fcs1 \af0\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {
tlch\fcs1 \ab\af0\afs24 \ltrch\fcs0 \b\f0\fs24\insrsid5841714\charrsid5841714 PROSECUTION BY INFORMATION}{tlch\fcs1 \ab\af0\afs24 \ltrch\fcs0 \b\f0\fs24\insrsid5841714 
EOL;
$document = str_replace($search1, '', $document);


// this one is also working now - thanks fyrye
$search2 = <<<'EOL'
\par {\listtext\pard\plain\ltrpar \s15 tlch\fcs1 \af0 \ltrch\fcs0 \insrsid5841714 \hich\af0\dbch\af0\loch\f0 5.\tab}}\pard\plain \ltrpar\s15\ql \fi720\li0i0\sl480\slmult1
\widctlpar\wrapdefault\aspalpha\aspnum\faauto\ls2\adjustrightin0\lin0\itap0\pararsid3021950\contextualspace tlch\fcs1 \af0\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {tlch\fcs1 \af0\afs24 \ltrch\fcs0 
\f0\fs24\insrsid5841714 The defendant has entered a plea of not guilty to the charge}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid5841714 s}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 
\f0\fs24\insrsid14111911 )}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid5841714  alleged in the accusatory instrument. To the extent that any of the pending non-felony charge}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{
tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid5841714 s}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid5841714 
 are based upon a hearsay complaint, rather than a non-hearsay information, the defendant hereby refuses to consent to be prosecuted by such complaint and demands to be prosecuted by a non-hearsay information }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 
\f0\fs24\insrsid14111911 (}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid5841714 CPL }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7\'a7}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid5841714  170.10[4][d]; 170.65[1]}{
tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid5841714 
EOL;
$document = str_replace($search2, '', $document);

// leaving this in even though it doesn't seem to make a difference
$search3 = str_replace(["
", "
"], ["
", "
"], $search3);




// This one still not replacing - most complicated

$search3 = <<<'EOL'
\par }\pard\plain \ltrpar\qc \li0i0\sl480\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustrightin0\lin0\itap0\pararsid5841714 tlch\fcs1 \af0\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {
tlch\fcs1 \ab\af0\afs24 \ltrch\fcs0 \b\f0\fs24\insrsid5841714\charrsid5841714 DEFECTIVE INFORMATION}{tlch\fcs1 \ab\af0\afs24 \ltrch\fcs0 \b\f0\fs24\insrsid5841714 
\par {\listtext\pard\plain\ltrpar \s15 tlch\fcs1 \af0 \ltrch\fcs0 \insrsid5841714 \hich\af0\dbch\af0\loch\f0 6.\tab}}\pard\plain \ltrpar\s15\ql \fi720\li0i0\sl480\slmult1
\widctlpar\wrapdefault\aspalpha\aspnum\faauto\ls2\adjustrightin0\lin0\itap0\pararsid3021950\contextualspace tlch\fcs1 \af0\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {tlch\fcs1 \af0\afs24 \ltrch\fcs0 
\f0\fs24\insrsid5841714 The defendant hereby moves, pursuant to CPL }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid5841714  170.30}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 
\f0\fs24\insrsid3021950 , to dismiss the accusatory or count charging the offense}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid3021950 s}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 
\f0\fs24\insrsid14111911 )}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid3021950  of }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 #deftodisword on the ground that it is defective. An accusatory instrument }{tlch\fcs1 \af0\afs24 
\ltrch\fcs0 \f0\fs24\insrsid14111911 (}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 or count thereof}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 
 is defective if it is not sufficient on itquote s face pursuant to the requirements of CPL }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306  100.40 }{tlch\fcs1 \af0\afs24 
\ltrch\fcs0 \f0\fs24\insrsid14111911 (}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 CPL }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306  170.35[1][a]}{
tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 ;}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid5841714 
\par {\listtext\pard\plain\ltrpar \s15 tlch\fcs1 \af0 \ltrch\fcs0 \insrsid13307306 \hich\af0\dbch\af0\loch\f0 7.\tab}}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 
To be sufficient on its face, a local criminal court accusatory which purports to qualify as an \'93information\'94 must satisfy the requirements set forth below:
\par {\listtext\pard\plain\ltrpar \s15 tlch\fcs1 \af0 \ltrch\fcs0 \insrsid13307306 \hich\af0\dbch\af0\loch\f0 a.\tab}}\pard \ltrpar
\s15\ql \fi-360\li1440i0\widctlpar\wrapdefault\aspalpha\aspnum\faauto\ls2\ilvl1\adjustrightin0\lin1440\itap0\pararsid13446461\contextualspace {tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 An information \'93
must contain an accusatory part and a factual part. The complainantquote s verification of the instrument is deemed to apply only to the }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 factual part thereof and not to the accusatory part.
\'94 }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 CPL }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 
\f0\fs24\insrsid13446461  100.15[1]}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 ;\line }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 
\par {\listtext\pard\plain\ltrpar \s15 tlch\fcs1 \af0 \ltrch\fcs0 \insrsid13446461 \hich\af0\dbch\af0\loch\f0 b.\tab}}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 The accusatory part \'93must designate the offense or offenses charged\'94 }{
tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 CPL }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 
 100.15[2]}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 ;\line 
\par {\listtext\pard\plain\ltrpar \s15 tlch\fcs1 \af0 \ltrch\fcs0 \insrsid13446461 \hich\af0\dbch\af0\loch\f0 c.\tab}The factual part \'93
must contain a statement of the complainant alleging facts of an evidentiary character supporting or tending to support the charges\'94 }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 
\f0\fs24\insrsid13446461 CPL }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461  100.15[3]; see also }{tlch\fcs1 \ai\af0\afs24 \ltrch\fcs0 
\i\f0\fs24\insrsid13446461\charrsid13446461 People v. Dumas}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 , 68 NY2d [1986]}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 
\f0\fs24\insrsid13446461 ;\line 
\par {\listtext\pard\plain\ltrpar \s15 tlch\fcs1 \af0 \ltrch\fcs0 \insrsid13446461 \hich\af0\dbch\af0\loch\f0 d.\tab}The allegations of the factual part, together with those of any supporting depositions which may accompany it, must \'93
provide reasonable cause to believe that the defendant committed the offense charged in the accusatory part of the information\'94 }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 
\f0\fs24\insrsid13446461 CPL }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461  100.40[1][b]}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{tlch\fcs1 
\af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 ;\line 
\par {\listtext\pard\plain\ltrpar \s15 tlch\fcs1 \af0 \ltrch\fcs0 \insrsid13446461 \hich\af0\dbch\af0\loch\f0 e.\tab}Finally, every element of the offense charged and the defendantquote s commission thereof must be established by \'93
non-hearsay allegations of the factual part of the information and/or of any supporting depositions\'94 }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 CPL }{tlch\fcs1 
\af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461  100.40[1][c]; }{tlch\fcs1 \ai\af0\afs24 \ltrch\fcs0 \i\f0\fs24\insrsid13446461\charrsid13446461 see also People v. Alejandro}{tlch\fcs1 
\af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 , 70 NY2d 133 [1987]}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 .
\par }\pard\plain \ltrpar\ql \li0i0\sl480\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustrightin0\lin0\itap0\pararsid13446461 tlch\fcs1 \af0\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {
tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 
EOL;
$document = str_replace($search3, '', $document);


header("Content-type: application/msword");
header("Content-disposition: inline; filename=$defendantphp-Omnibus.doc");
echo ($document);
}
?>
  • 写回答

1条回答 默认 最新

  • dqlk31541 2019-06-13 13:17
    关注

    In php the backslash is an escape sequence, regardless of single or double quote encapsulation.

    Since you are using single quote encapsulation, your search argument with:

    \'a7\'a7
    

    Is only escaping the single quote characters, resulting in:

    'a7'a7
    

    But is literally \'a7\'a7 in the RTF file.

    To resolve the issue, you need to escape the backslash and quote characters with:

    \\\'a7\\\'a7
    

    Which will escape the backslash and the single quote resulting in:

    \'a7\'a7
    

    Additionally it is best-practice to always escape literal backslashes, by using double backslash \\, to avoid complications such as the one you encountered.

    To specify a literal single quote, escape it with a backslash (\). To specify a literal backslash, double it (\\). All other instances of backslash will be treated as a literal backslash: this means that the other escape sequences you might be used to, such as or , will be output literally as specified rather than having any special meaning. [sic]

    $document = str_replace([
        // this one works
        '\\par }\\pard\\plain \\ltrpar\\qc \\li0\i0\\sl480\\slmult1\\widctlpar\\wrapdefault\\aspalpha\\aspnum\\faauto\\adjustright\in0\\lin0\\itap0\\pararsid5841714 \tlch\\fcs1 \\af0\\afs22\\alang1025 \\ltrch\\fcs0 \\f31506\\fs22\\lang1033\\langfe1033\\cgrid\\langnp1033\\langfenp1033 {
    \tlch\\fcs1 \\ab\\af0\\afs24 \\ltrch\\fcs0 \\b\\f0\\fs24\\insrsid5841714\\charrsid5841714 PROSECUTION BY INFORMATION}{\tlch\\fcs1 \\ab\\af0\\afs24 \\ltrch\\fcs0 \\b\\f0\\fs24\\insrsid5841714 ',
        //this one does not (it does now...)
        '\\par {\\listtext\\pard\\plain\\ltrpar \\s15 \tlch\\fcs1 \\af0 \\ltrch\\fcs0 \\insrsid5841714 \\hich\\af0\\dbch\\af0\\loch\\f0 5.\\tab}}\\pard\\plain \\ltrpar\\s15\\ql \\fi720\\li0\i0\\sl480\\slmult1
    \\widctlpar\\wrapdefault\\aspalpha\\aspnum\\faauto\\ls2\\adjustright\in0\\lin0\\itap0\\pararsid3021950\\contextualspace \tlch\\fcs1 \\af0\\afs22\\alang1025 \\ltrch\\fcs0 \\f31506\\fs22\\lang1033\\langfe1033\\cgrid\\langnp1033\\langfenp1033 {\tlch\\fcs1 \\af0\\afs24 \\ltrch\\fcs0 
    \\f0\\fs24\\insrsid5841714 The defendant has entered a plea of not guilty to the charge(s) alleged in the accusatory instrument. To the extent that any of 
    the pending non-felony charge(s) are based upon a hearsay complaint, rather than a non-hearsay information, the defendant hereby refuses to consent to be prosecuted by such complaint and demands to be prosecuted by a non-hearsay information (CPL \\\'a7\\\'a7
     170.10[4][d]; 170.65[1])',
    ], '', $document);
    

    Alternatively, to circumvent the need of escaping backslashes and quotes, you can convert your search argument to the NOWDOC syntax.

    The construct is ideal for embedding PHP code or other large blocks of text without the need for escaping. [sic]

    Using nowdoc syntax, backslashes are always treated literally.

    $search = <<<'EOL'
    \par }\pard\plain \ltrpar\qc \li0i0\sl480\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustrightin0\lin0\itap0\pararsid5841714 tlch\fcs1 \af0\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {
    tlch\fcs1 \ab\af0\afs24 \ltrch\fcs0 \b\f0\fs24\insrsid5841714\charrsid5841714 PROSECUTION BY INFORMATION}{tlch\fcs1 \ab\af0\afs24 \ltrch\fcs0 \b\f0\fs24\insrsid5841714 
    EOL;
    $document = str_replace($search, '', $document);
    
    $search = <<<'EOL'
    \par {\listtext\pard\plain\ltrpar \s15 tlch\fcs1 \af0 \ltrch\fcs0 \insrsid5841714 \hich\af0\dbch\af0\loch\f0 5.\tab}}\pard\plain \ltrpar\s15\ql \fi720\li0i0\sl480\slmult1
    \widctlpar\wrapdefault\aspalpha\aspnum\faauto\ls2\adjustrightin0\lin0\itap0\pararsid3021950\contextualspace tlch\fcs1 \af0\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {tlch\fcs1 \af0\afs24 \ltrch\fcs0 
    \f0\fs24\insrsid5841714 The defendant has entered a plea of not guilty to the charge(s) alleged in the accusatory instrument. To the extent that any of 
    the pending non-felony charge(s) are based upon a hearsay complaint, rather than a non-hearsay information, the defendant hereby refuses to consent to be prosecuted by such complaint and demands to be prosecuted by a non-hearsay information (CPL \'a7\'a7
     170.10[4][d]; 170.65[1])
    EOL;
    $document = str_replace($search, '', $document);
    

    Resulting document: https://drive.google.com/file/d/1Qw8C1S0AAjgZg8xEy5onmSCptNvRGmuh/view?usp=sharing

    Ensure that your PHP editor is using DOS line endings <kbd>CRLF</kbd>, as your RTF file uses <kbd>CRLF</kbd>.

    To ensure proper line endings you can convert the search argument from DOS to UNIX and then from UNIX to DOS, by using.

    $search = <<<'EOL'
    EOL;
    $search = str_replace(["
    ", "
    "], ["
    ", "
    "], $search);
    

    This is used to fix the search text before performing the replacement. Do not use on the document string.


    Additional Suggestions

    You should not need to use echo iconv('UTF-8', 'ISO-8859-1', $document); since your source document is in UTF-8. Using iconv may cause complications, if a UTF-8 encoded character can not be converted to ISO-8859-1.

    Your usage of mb_http_input('UTF-8'); is incorrect. Which is used to retrieve the input encoding of the specified type. The type argument should be one of "G" for GET, "P" for POST, "C" for COOKIE, "S" for string, "L" for list, and "I" for the whole list (will return array).

    Unless changed in your server configurations, PHP uses UTF-8 by default as of version 5.6+. So you can remove the multi-byte string functions.

    //mb_internal_encoding('UTF-8'); 
    //mb_http_output('UTF-8'); 
    //mb_regex_encoding('UTF-8'); 
    

    You can validate the settings before doing so by using:

    Example https://3v4l.org/bZukb

    var_dump(array(
        mb_internal_encoding(),
        mb_http_output(),
        mb_regex_encoding(),
    ));
    

    You can also remove the Content-Length header, as they are generally redundant in most environments, since the web server processes the response prior to sending it the user-agent and including it can cause issues with certain user-agents, when the length does not match the actual content sent.

    //header("Content-length: ".strlen($document));
    

    In your current script, the strlen is processing a UTF-8 encoded string, but the response is an ISO-8859-1 encoded string. Resulting in the specified Content-length header to be larger than the actual response. Which may cause certain user-agents to hang expecting additional content.


    Edit with updated scope

    It appears you updated the RTF content, as I am unable to find several portions of the search3text.

    However the issue appears to be caused by applying the placeholder replacements (#deftodisword, #judgeword, #crnumword, #adaword, etc), prior to applying your search text replacements.

    This changes the content of the document string, causing your search text to no longer match. For example the line below contains #deftodisword:

    \f0\fs24\insrsid14111911 )}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid3021950 of }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 #deftodisword on the ground that it is defective. An accusatory instrument }{tlch\fcs1 \af0\afs24

    To resolve the issue, replace the placeholders after executing the search replacements on the document.

    As a last suggestion to improve performance slightly, you can combine the str_replace calls by using string arrays.

    Example: https://3v4l.org/TbFa4

    //returns an array of the combined sanitized search texts
    $search = str_replace(["
    ", "
    "], ["
    ", "
    "], [$search1, $search2, $search3]);
    
    $document = str_replace($search, '', $document);
    
    $document = str_replace(['#defendantword', '#judgeword'], [$defendantphp, $judgephp], $document);
    

    Full example:

    $search1 = <<<'EOL'
    \par }\pard\plain \ltrpar\qc \li0i0\sl480\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustrightin0\lin0\itap0\pararsid5841714 tlch\fcs1 \af0\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {
    tlch\fcs1 \ab\af0\afs24 \ltrch\fcs0 \b\f0\fs24\insrsid5841714\charrsid5841714 PROSECUTION BY INFORMATION}{tlch\fcs1 \ab\af0\afs24 \ltrch\fcs0 \b\f0\fs24\insrsid5841714 
    EOL;
    $search2 = <<<'EOL'
    \par {\listtext\pard\plain\ltrpar \s15 tlch\fcs1 \af0 \ltrch\fcs0 \insrsid5841714 \hich\af0\dbch\af0\loch\f0 5.\tab}}\pard\plain \ltrpar\s15\ql \fi720\li0i0\sl480\slmult1
    \widctlpar\wrapdefault\aspalpha\aspnum\faauto\ls2\adjustrightin0\lin0\itap0\pararsid3021950\contextualspace tlch\fcs1 \af0\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {tlch\fcs1 \af0\afs24 \ltrch\fcs0 
    \f0\fs24\insrsid5841714 The defendant has entered a plea of not guilty to the charge}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid5841714 s}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 
    \f0\fs24\insrsid14111911 )}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid5841714  alleged in the accusatory instrument. To the extent that any of the pending non-felony charge}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{
    tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid5841714 s}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid5841714 
     are based upon a hearsay complaint, rather than a non-hearsay information, the defendant hereby refuses to consent to be prosecuted by such complaint and demands to be prosecuted by a non-hearsay information }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 
    \f0\fs24\insrsid14111911 (}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid5841714 CPL }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7\'a7}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid5841714  170.10[4][d]; 170.65[1]}{
    tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid5841714 
    EOL;
    $search3 = <<<'EOL'
    \par }\pard\plain \ltrpar\qc \li0i0\sl480\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustrightin0\lin0\itap0\pararsid5841714 tlch\fcs1 \af0\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {
    tlch\fcs1 \ab\af0\afs24 \ltrch\fcs0 \b\f0\fs24\insrsid5841714\charrsid5841714 DEFECTIVE INFORMATION}{tlch\fcs1 \ab\af0\afs24 \ltrch\fcs0 \b\f0\fs24\insrsid5841714 
    \par {\listtext\pard\plain\ltrpar \s15 tlch\fcs1 \af0 \ltrch\fcs0 \insrsid5841714 \hich\af0\dbch\af0\loch\f0 6.\tab}}\pard\plain \ltrpar\s15\ql \fi720\li0i0\sl480\slmult1
    \widctlpar\wrapdefault\aspalpha\aspnum\faauto\ls2\adjustrightin0\lin0\itap0\pararsid3021950\contextualspace tlch\fcs1 \af0\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {tlch\fcs1 \af0\afs24 \ltrch\fcs0 
    \f0\fs24\insrsid5841714 The defendant hereby moves, pursuant to CPL }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid5841714  170.30}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 
    \f0\fs24\insrsid3021950 , to dismiss the accusatory or count charging the offense}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid3021950 s}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 
    \f0\fs24\insrsid14111911 )}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid3021950  of }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 #deftodisword on the ground that it is defective. An accusatory instrument }{tlch\fcs1 \af0\afs24 
    \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 or count thereof}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 
     is defective if it is not sufficient on itquote s face pursuant to the requirements of CPL }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306  100.40 }{tlch\fcs1 \af0\afs24 
    \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 CPL }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306  170.35[1][a]}{
    tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 ;}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid5841714 
    \par {\listtext\pard\plain\ltrpar \s15 tlch\fcs1 \af0 \ltrch\fcs0 \insrsid13307306 \hich\af0\dbch\af0\loch\f0 7.\tab}}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 
    To be sufficient on its face, a local criminal court accusatory which purports to qualify as an \'93information\'94 must satisfy the requirements set forth below:
    \par {\listtext\pard\plain\ltrpar \s15 tlch\fcs1 \af0 \ltrch\fcs0 \insrsid13307306 \hich\af0\dbch\af0\loch\f0 a.\tab}}\pard \ltrpar
    \s15\ql \fi-360\li1440i0\widctlpar\wrapdefault\aspalpha\aspnum\faauto\ls2\ilvl1\adjustrightin0\lin1440\itap0\pararsid13446461\contextualspace {tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 An information \'93
    must contain an accusatory part and a factual part. The complainantquote s verification of the instrument is deemed to apply only to the }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 factual part thereof and not to the accusatory part.
    \'94 }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 CPL }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 
    \f0\fs24\insrsid13446461  100.15[1]}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 ;\line }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 
    \par {\listtext\pard\plain\ltrpar \s15 tlch\fcs1 \af0 \ltrch\fcs0 \insrsid13446461 \hich\af0\dbch\af0\loch\f0 b.\tab}}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 The accusatory part \'93must designate the offense or offenses charged\'94 }{
    tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 CPL }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 
     100.15[2]}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 ;\line 
    \par {\listtext\pard\plain\ltrpar \s15 tlch\fcs1 \af0 \ltrch\fcs0 \insrsid13446461 \hich\af0\dbch\af0\loch\f0 c.\tab}The factual part \'93
    must contain a statement of the complainant alleging facts of an evidentiary character supporting or tending to support the charges\'94 }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 
    \f0\fs24\insrsid13446461 CPL }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461  100.15[3]; see also }{tlch\fcs1 \ai\af0\afs24 \ltrch\fcs0 
    \i\f0\fs24\insrsid13446461\charrsid13446461 People v. Dumas}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 , 68 NY2d [1986]}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 
    \f0\fs24\insrsid13446461 ;\line 
    \par {\listtext\pard\plain\ltrpar \s15 tlch\fcs1 \af0 \ltrch\fcs0 \insrsid13446461 \hich\af0\dbch\af0\loch\f0 d.\tab}The allegations of the factual part, together with those of any supporting depositions which may accompany it, must \'93
    provide reasonable cause to believe that the defendant committed the offense charged in the accusatory part of the information\'94 }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 
    \f0\fs24\insrsid13446461 CPL }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461  100.40[1][b]}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{tlch\fcs1 
    \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 ;\line 
    \par {\listtext\pard\plain\ltrpar \s15 tlch\fcs1 \af0 \ltrch\fcs0 \insrsid13446461 \hich\af0\dbch\af0\loch\f0 e.\tab}Finally, every element of the offense charged and the defendantquote s commission thereof must be established by \'93
    non-hearsay allegations of the factual part of the information and/or of any supporting depositions\'94 }{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 CPL }{tlch\fcs1 
    \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461  100.40[1][c]; }{tlch\fcs1 \ai\af0\afs24 \ltrch\fcs0 \i\f0\fs24\insrsid13446461\charrsid13446461 see also People v. Alejandro}{tlch\fcs1 
    \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 , 70 NY2d 133 [1987]}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 .
    \par }\pard\plain \ltrpar\ql \li0i0\sl480\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustrightin0\lin0\itap0\pararsid13446461 tlch\fcs1 \af0\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {
    tlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 
    EOL;
    
    //ensure search texts PHP line endings match RTF content
    $search = str_replace(["
    ", "
    "], ["
    ", "
    "], [$search1, $search2, $search3]);
    
    //replace search texts
    $document = str_replace($search, '', $document);
    
    //replace placeholders
    $document = str_replace(
        ['#defendantword', '#judgeword', '#crnumword', '#adaword', '#attyword', '#motargdateword', '#deftodisword', '#crimedateword', '#motargdateword', '#accusdateword', '#allcrimeschargedword'],
        [$defendantphp, $judgephp, $crnumphp, $adaphp, $attyphp, $motargdatephp, $deftodisphp, $crimedatephp, $motsigndatephp, $accusdatephp, $allcrimeschargedphp],
        $document
    );
    
    header('Content-type: application/msword');
    header(sprintf('Content-disposition: inline; filename=%s-Omnibus.doc', $defendantphp));
    echo $document;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵